21754

Is Jinja2 documentation out of date?

Question:

I am getting 2 errors by doing simple things that follow the documentation here <a href="http://jinja.pocoo.org/docs/templates/" rel="nofollow">http://jinja.pocoo.org/docs/templates/</a> :

{% if lang == 'fr' %} bonjour {% elif lang == 'en' %} hello {% endif %}

TemplateSyntaxError: Invalid block tag: 'elif', expected 'else' or 'endif'

and

{% extends "skeleton.html" %} {% block a_name %} {{ super() }} I am extended {% endblock %}

where skeleton.html contains {% block a_name %} hi I am skeleton {% endblock %}

TemplateSyntaxError: Could not parse the remainder: '()' from 'super()

Any clue on that ? Thanks

Answer1:

I was using jinja2 with Google App Engine. Well, I <em>thought</em> I was doing so, but a closer look to the exception and the file stack trace, showed that it said "django".

For future reference, doing

self.response.write(template.render(template_values))

will make appengine render the template with django. Even if it says jinja2/latest in app.yaml under libraries.

You must import jinja2 and explicitly use template = jinja2.get_environment... to make it work. See <a href="https://developers.google.com/appengine/docs/python/gettingstartedpython27/templates?hl=fr" rel="nofollow">https://developers.google.com/appengine/docs/python/gettingstartedpython27/templates?hl=fr</a> for more info

Thanks for setting me on the track @Blender

Recommend

  • Return Multiple calendar events
  • Am I converting local space to world space coordinates properly?
  • Scroll a particular ListView item into view
  • leaflet marker not displaying in certain contexts
  • Express.js : POST data as KEY of a req.body object instead of VALUE of req.body?
  • Prevent page break in text block with iText, XMLWorker
  • Javascript/Jquery runs fast in desktop browsers, but slow in mobile/smartphone browsers…should I spl
  • C++ friend class std::vector
  • SyntaxError: (irb):26: both block arg and actual block given
  • Clear fused location provider's location for testing
  • Update Google Maps traffic layer without page reloading
  • Trying to get the char code of ENTER key
  • Android Studio 1.3 RC3. Google Play services out of date. Requires 7571000 but found 6774470
  • android google indoor map
  • Android Google Maps API v2 start navigation
  • Creating Java object from class name with constructor, which contains parameters [duplicate]
  • how to avoid repetitive constructor in children
  • Insert new calendar with SyncAdapter- Calendar API Android
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • Functions in global context
  • Seeking advice on Jetty HttpClient Hang
  • how to do an event when i swipe from fragment to the other
  • Deleting and Updating values from a cusrsor adapter
  • Volley JsonObjectRequest send headers in GET Request
  • Is possible to count alias result on mysql
  • Possible to stop flickering java tooltip in heavyweight mode?
  • Check if a string to interpolate provides expected placeholders
  • Importing jscolor library in angular 2
  • Google cloud sdk not working when python points python3
  • Akka Routing: Reply's send to router ends up as dead letters
  • PHP: When would you need the self:: keyword?
  • How to get icons for entities from eclipse?
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • using HTMLImports.whenReady not working in chrome
  • Memory offsets in inline assembly
  • unknown Exception android
  • JaxB to read class hierarchy
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Android Heatmap on canvas or ImageView