Indentation aware templates

Let’s say I’m generating Pug templates (to be used by Javascript) from Elixir. It makes sense to generate the Pug templates using EEx, like this:

div(id="first")
  div(id="second")
    <%= inner_pug %>

But Pug is indentation-sensitive, and if inner_pug has more than one line, the lines after the first won’t be indented correctly. Is there a generally accepted way to achieve this? I can indent inner_pug outside of the template, of course, I’m just asking to know if there is a better way.

Thanks in advance.

1 Like

I don’t know. For some reason, though, if it’s inside some kind of block (ie for noodle <- noodles do ... end)

<% some block do %>
div(id="first")
    div(id="second")
        <%= inner_pug %>
<% end %>

The indentation is preserved