Git Product home page Git Product logo

Comments (5)

pydanny avatar pydanny commented on June 15, 2024 5

I had a similar problem with creating a Django cookiecutter template (https://github.com/pydanny/cookiecutter-dj-package) that I need to go fix. πŸ˜‰

I think escaping (http://jinja.pocoo.org/docs/templates/#escaping) is the answer. Try:

{{ {{ url_for('home') }} }}

If that doesn't work, try:

{% raw %}
<p>Go <a href="{{ url_for('home') }}">Home</a></p>
{% endraw %}

from cookiecutter.

audreyfeldroy avatar audreyfeldroy commented on June 15, 2024 2

You can also escape just the {{ like this:

{{ "{{" }}

Same for escaping }} with {{ "}}" }}.

I do something similar to escape { here: https://github.com/audreyr/cookiecutter-jquery/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/src/jquery.%7B%7Bcookiecutter.repo_name%7D%7D.coffee#L40

The downside is that Jinja-templated templates are not the prettiest to read. (Any ideas how to improve this, anyone?)

I will add this to the documentation when I get a chance, since it's a common scenario.

from cookiecutter.

pydanny avatar pydanny commented on June 15, 2024

Here is how I fixed it: https://github.com/pydanny/cookiecutter-dj-package/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/%7B%7Bcookiecutter.app_name%7D%7D/templates/%7B%7Bcookiecutter.app_name%7D%7D/base.html

from cookiecutter.

sloria avatar sloria commented on June 15, 2024

OK, using the {% raw %} tag in all my templates worked well. Thanks for your help.

from cookiecutter.

pydanny avatar pydanny commented on June 15, 2024

@audreyr - I think this is resolved. Can you close please?

from cookiecutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.