straight-shoota / crinja

Implementation of Jinja2 template language in Crystal
https://straight-shoota.github.io/crinja/
Other
122 stars 11 forks source link

Add support of Jinja2 "Do" tag #33

Closed n-rodriguez closed 4 years ago

n-rodriguez commented 4 years ago

From Jinja2 doc : https://jinja.palletsprojects.com/en/2.11.x/extensions/#expression-statement

Thank you!

n-rodriguez commented 4 years ago

Could you add some documentation to the tag class? A description and link to jinja2 docs (i.e. the PR message) plus a short usage example would be great.

Done!

I'm not sure about adding it to default tags. So far, most of Crinja's library should be mostly compatible with Jinja2 defaults. So maybe it would be better to have this tag as an extension in Crinja, too.

At the beginning I wanted to implement the do tag on my side using env.tags << MyTag.new but it didn't work so I ended up with this PR.

straight-shoota commented 4 years ago

At the beginning I wanted to implement the do on my side using env.tags << MyTag.new but it didn't work so I ended up with this PR.

Oh, that should really work. Can you still reproduce that? It's definitely an error. I mean the code in lib/tag.cr doesn't do anything else.

Nonetheless, it surely makes sense to have the do tag in Crinja's default library. So thanks for this PR! I'm just not 100% confident whether it should be enabled by default (i.e. included in TAGS list used in register_defaults).

n-rodriguez commented 4 years ago

Oh, that should really work. Can you still reproduce that? It's definitely an error.

Hi there! Finally I could make it work in my own project. Do you still want this PR? I think it could be useful for other people too.

n-rodriguez commented 4 years ago

I'd definitely like to add this, and a apart from a minor doc improvement this looks good to merge!

done!

straight-shoota commented 4 years ago

Awesome, thanks!