ventojs / vento

🌬 A template engine for Deno & Node
https://vento.js.org/
MIT License
153 stars 9 forks source link

Allow the trimming syntax in comments #70

Closed valtlai closed 1 week ago

valtlai commented 1 week ago

I would expect the following comments to trim white space before them:

/*
  Content-Security-Policy:
    {#- #} default-src 'none';
    {#- #} style-src 'self';
    {#- #} base-uri 'none';

So the result would be:

/*
  Content-Security-Policy: default-src 'none'; style-src 'self'; base-uri 'none';

The code works like this in Nunjucks. In Vento, the - character is part of the comment, so it doesn’t do anything, and a syntax like {{-# #}} is a parsing error.

Therefore, I propose that we add support for the {{#- start tag and the -#}} end tag (or {{-# and #-}}, respectively, if they’re better – personally I don’t think so).

oscarotero commented 1 week ago

that's a good idea. I just implemented this and will be available in the next version of Vento.

valtlai commented 1 week ago

Thank you so much for the quick fix – and for the whole project: it’s so great to have modern, actively maintained templating engine.