Pugjs (jade template) - delete strings in a block expression

I find it difficult to delete a new line between elements in an instruction eachin a pug js template (formerly jade)

My code looks like this. I would like to have spaces between elements liwhen rendering HTML, so I'm trying to use comments between them.

mixin nav(links)
  ul.nav <!--
    each link in links
      |-->
      li(class=(section == link.key ? 'active' : null)): a(href=link.href)= link.label
      |<!--
    |-->

Now it gives me this result:

<ul class="nav"><!---->
  <li class="active"><a href="/">Home</a></li><!---->
  <li><a href="/foo">Foo</a></li><!---->
  <li><a href="/bar">Bar</a></li><!---->
  <li><a href="/yada">Yada</a></li><!---->
</ul>

Is there a good way to tell a pug? I do not want spaces between these elements or is it a language restriction? I am using KeystoneJS, which in the development environment will tell the pug interpreter to prefix the HTML. I would like the product to be consistent throughout the development process to production (and not write a workaround in CSS that is negated by minimization in the production environment)

+4

Source: https://habr.com/ru/post/1681760/


All Articles