dnaka91 / cargo-hatch

Hatch new projects like a chick coming out of its egg
GNU Affero General Public License v3.0
7 stars 1 forks source link

custom delimiters for tera #9

Open ModProg opened 1 year ago

ModProg commented 1 year ago

I have a file using terra like templates inside a template.

So having the ability to change the delimter to some other character would be great.

Related tera issue: https://github.com/Keats/tera/issues/343

Keats commented 1 year ago

I don't know cargo-hatch but the way I handle it in https://github.com/Keats/kickstart is to have a way to ignore files from the generation. Now it depends whether you have values you do want to change in those file: that's more complex in that case. Just trying to give another idea as that's not going to happen in Tera itself for a long time

ModProg commented 1 year ago

Now it depends whether you have values you do want to change in those file: that's more complex in that case.

well thats exactly what I try to do :(, but maybe I can hack something together by doing some search and replace before calling tera

Keats commented 1 year ago

You can wrap things in {% raw %} {% endraw %} for the things that shouldn't be replaced

ModProg commented 1 year ago

You can wrap things in {% raw %} {% endraw %} for the things that shouldn't be replaced

Maybe that is the quickest thing to set up. thanks

dnaka91 commented 1 year ago

Thank you for helping out on this @Keats!

Looks like {% raw %} {% endraw %} is the best way to go. @ModProg I'll leave the issue open, and just let me know if there's anything I can help with to get it working for you 👍 (or close it, if that solved the problem).

ModProg commented 1 year ago

The only thing that might be interesting is the "ignore for templating".

But until this is resolved in tera which might be a while there is no need to implement custom delimiters here :)

dnaka91 commented 1 year ago

True, currently there is only the .hatchignore, which skips the file altogether, not even copying it over.

As it turns out, I actually used the {% raw %} myself already in one of my own templates, that I just didn't use for a long time. There I have askama HTML templates, which happen to use the same syntax, so I mixed it with that special attribute here and there.

ModProg commented 1 year ago

As it turns out, I actually used the {% raw %} myself already in one of my own templates, that I just didn't use for a long time. There I have askama HTML templates, which happen to use the same syntax, so I mixed it with that special attribute here and there.

Maybe we should add it to the documentation, as for these templates you seldom need the full feature set from tera, but raw is quite useful.