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

escaped delimters yield escape characters in output #169

Closed
softprops opened this issue Jul 29, 2017 · 8 comments
Closed

escaped delimters yield escape characters in output #169

softprops opened this issue Jul 29, 2017 · 8 comments
Assignees

Comments

@softprops
Copy link
Contributor

softprops commented Jul 29, 2017

I just ran into a use case where I needed my handle bars templates to yield {{foo}} in their output. This seems to be a feature in handlebars js and it does seem to be part of the grammar here However the delimiter is left behind in the rendered output ( \\{{foo}} ). Is there a way to both specify {{foo}} in a handbars template and have it rendered in literal form {{foo}}?

@sunng87 sunng87 self-assigned this Jul 30, 2017
@sunng87
Copy link
Owner

sunng87 commented Jul 30, 2017

At the moment \\ escape is not implemented. Let me find some time to work on it.

@softprops
Copy link
Contributor Author

It looks like it's implemented in terms of avoid evaling tags but there's just a little bit more to strip off the escape pattern from the raw text tokens. I'm not sure if you can do that directly in pest but one example place where it may be possible is where the pest output is being unpacked. Looking around this area to maybe do some kind of post processing. I think that's roughly what the js impl did

@sunng87
Copy link
Owner

sunng87 commented Jul 31, 2017

Nice. For now we have escape check in pest grammar and \\{{ will be treated as raw_text. It seems we just need to replace \\{{ with {{ in raw_text.

@softprops
Copy link
Contributor Author

Would you be open to a pr if I can getting sooner than you? Context: I'm doing some prep work for a company hackathon by setting up some project templates with https://github.com/softprops/porteurbars which uses this lib as the underlying template engine. I ran into a problem with the escaped delimiter when I realized that one of these templates needed to emit {{foo}} in its output. The hackathon doesn't start until this thurs and friday but I wanted to try to get some prep work done early. Well also likely be using this tool for other companynproject templates in the future.

@sunng87
Copy link
Owner

sunng87 commented Jul 31, 2017

Sure! Please make your PR for this. Thank you @softprops

@softprops
Copy link
Contributor Author

Submitted hopefully a sane pr over here #170

@sunng87
Copy link
Owner

sunng87 commented Aug 1, 2017

Released in 0.28.2

@sunng87 sunng87 closed this as completed Aug 1, 2017
@softprops
Copy link
Contributor Author

Awesome thanks!

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

2 participants