ring

manas_marthi 2025-04-20T06:03:36.858969Z

Hi, This is a question about Selmer templates. My Selmer templates have include selmer tag to include header.html. When I request is a htmx request and has hx-request header in it, I don't want the include to happen? I tried a if tag, but it did not work. Has anyone tried it?

yogthos 2025-04-20T13:57:46.838289Z

include is a bit special because it gets resolved during template compile time, so you can't do conditional includes when rendering

πŸ‘πŸ½ 1
yogthos 2025-04-20T13:58:11.775629Z

you could move the if into your include though and then have it render its content conditionally

πŸ‘πŸ½ 1
Patrix 2025-04-20T17:58:51.888229Z

I do it the other way around, with the conditional in my Clojure code rather than in the template. In my request handler, if there’s the hx-request header I only render a template with the actual content. Without that header, I render a template with the headings, footer, etc which also then includes the previously mentioned template with the content.

manas_marthi 2025-04-20T18:38:56.458829Z

Moving the condition to the include file sounds fine to me..

manas_marthi 2025-04-20T18:39:00.617409Z

thank you

πŸ‘ 1
manas_marthi 2025-04-20T06:04:32.203499Z

Hi @yogthos, tagging you for obvious reasons πŸ™‚