Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support escaping startTags (and endTags) in the template #22

Open
mashedkeyboard opened this issue Jun 19, 2020 · 1 comment
Open

Support escaping startTags (and endTags) in the template #22

mashedkeyboard opened this issue Jun 19, 2020 · 1 comment

Comments

@mashedkeyboard
Copy link

Hey, thanks for this awesome library!

At present, there is no way to include a startTag in the template string without the engine picking up on it as a tag:

n := bytes.Index(s, a)

I'd like to use this with some user defined templates, where there might well be a use case for them having whatever character I choose for the startTag in their template string proper. Using backslashes to escape would be the obvious option, but there's currently no functionality for anything of this sort in the library as far as I can see - so consider this a feature request :)

Cheers!

@markuschaaf
Copy link

This is not needed. You can reserve a special insert name (e.g. the empty one) for the start-tag. Like this:

t := fasttemplate.New( "How to escape the $$-tag?", "$", "$" )
t.Execute( os.Stdout, map[ string ] interface{} { "": "$" })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants