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

Print double curly braces without nunjucks interfering? #604

Closed
tyronedougherty opened this issue Dec 9, 2015 · 3 comments
Closed

Print double curly braces without nunjucks interfering? #604

tyronedougherty opened this issue Dec 9, 2015 · 3 comments

Comments

@tyronedougherty
Copy link

I've got a large angular app that I'm converting to have some partials delivered by nunjucks server side.

Obviously both angular and nunjucks both use the double curly syntax when rendering variables

{{variable}}

How do I escape the curly braces from nunjucks so they are printed in the rendered HTML?
I know you can do it with the following syntax but I find this rather clumsy for doing it inline, as with so much of angular's implementation

{% raw %}
{{someAngularVariable}}
{% endraw %}

In the Laravel Blade templating engine, they use a syntax like this:

@{{someAngularVariable}}

which escapes and simply renders {{someAngularVariable}} in the HTML. Is there a similar short syntax that will allow this?

Many thanks

@carljm
Copy link
Contributor

carljm commented Dec 9, 2015

There isn't a shorter way to escape the default nunjucks syntax, but you might find this to be an even better solution: https://mozilla.github.io/nunjucks/api.html#customizing-syntax

@carljm carljm closed this as completed Dec 9, 2015
@jaredreich
Copy link

Why was this issue closed? I think it should be re-opened with the intent of adding short syntax like @tyronedougherty mentioned.

This would particularly be great for email templates where using nunjucks to build your own templates, then wanting to still send {{ variableName }} to the email provider that performs further substitutions.

@rbfonbuena
Copy link

Searching for the same issue and found the answer in the Jinja docs. Use {{ '{{variable}}' }} to get the literal output.

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

No branches or pull requests

4 participants