Note that there are some explanatory texts on larger screens.

plurals
  1. POWhich is the preferred method to use jinja2 on App Engine?
    primarykey
    data
    text
    <p>I originally implemented Jinja2 on App Engine using the examples shown on the App Engine site here: <a href="https://developers.google.com/appengine/docs/python/gettingstartedpython27/templates" rel="noreferrer">https://developers.google.com/appengine/docs/python/gettingstartedpython27/templates</a> where jinja2 is imported directly:</p> <pre><code>import jinja2 import os jinja_environment = jinja2.Environment( loader=jinja2.FileSystemLoader(os.path.dirname(__file__))) class MainPage(webapp2.RequestHandler): def get(self): greetings = 'somestring' template_values = { 'greetings': greetings, } template = jinja_environment.get_template('index.html') self.response.out.write(template.render(template_values)) </code></pre> <p>But I'm currently bolting on Simpleauth (<a href="https://github.com/crhym3/simpleauth" rel="noreferrer">https://github.com/crhym3/simpleauth</a>) which follows the implementation that Nick Johnson described here: <a href="http://blog.notdot.net/2011/11/Migrating-to-Python-2-7-part-2-Webapp-and-templates" rel="noreferrer">http://blog.notdot.net/2011/11/Migrating-to-Python-2-7-part-2-Webapp-and-templates</a> where jinja2 is imported from webapp2_extras:</p> <pre><code>import os import webapp2 from webapp2_extras import jinja2 class BaseHandler(webapp2.RequestHandler): @webapp2.cached_property def jinja2(self): return jinja2.get_jinja2(app=self.app) def render_template(self, filename, **template_args): self.response.write(self.jinja2.render_template(filename, **template_args)) class IndexHandler(BaseHandler): def get(self): self.render_template('index.html', name=self.request.get('name')) </code></pre> <p><strong>Which of these is the preferred method for using jinja2?</strong> (They don't seem to play together nicely, and would prefer to standardize on the best option.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload