ventojs / vento

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

Support vento templating within content files (html or markdown files) #10

Closed Brixy closed 1 year ago

Brixy commented 1 year ago

Thank you very much for vento! It is so ‘simple’, sane and modern compared to other template languages. I am converting almost a dozen web projects to vento (from Nunjucks or Liquid).


I would like to use vento in content files, i.e. .md and .html files.

A simple use case would be an iterator in a blog.html file:

{{ for item of pages }}
…
{{ /for }}

Basically it works as expected. Yet vento throws an error if a content file contains

Would it be possible to only call vento within {{}}? (Nunjucks does not break for the same use case.)

Thank you very much.

oscarotero commented 1 year ago

Vento should be called only within {{ and }} tags. Can I see a example of a breaking code?

Brixy commented 1 year ago

Thanks for your reply!

This works (as a excerpt from an HTML or markdown file):

const result = await env.runString("<h1>Test</h1><script>let name = 'Gandalf'; console.log('Hi', name, '.');</script>");

But this fails:

const result = await env.runString("<h1>Test</h1><script>let name = 'Gandalf'; console.log(`Hi ${name}.`);</script>");

Another real world use case is the following line which throws an error if the JS file contains backticks or curly braces.

{{ include "script.js }}
oscarotero commented 1 year ago

Ok, I'll take a look. Thanks!

oscarotero commented 1 year ago

v0.7.2 was released, including a fix for this issue.

Brixy commented 1 year ago

v0.7.2 was released, including a fix for this issue.

Wow, thank you very much. Everything is working as expected.