python - Set Mako as the default template renderer in Bottle.py -


is there way in bottle can set mako default template renderer.

this code wanted execute:

app.route(path='/', method='get', callback=func, apply=[auth], template='index.html')

where:

func       : function returns value (a dict) auth       : decorator authentication index.html : displays values "func" , contains "mako" syntax 

i have tried:

  • changing .html .mako
  • used renderer plugin: app.route(..., renderer='mako')
  • tried different patterns: # used '.mako', 'index.mako', 'index.html.mako'

also looked inside bottle object didn't saw hint set/change default engine:

# print objects contains "template" keyword, object itself, , value in dir(app):     if 'template' in i.lower():         print '{}: {}'.format(i, getattr(app, i)) 

you can return mako template route function:

from bottle import mako_template template  def func():     ...     return template('mytemplate.mako') 

edit:

bottle.mako_view may you're looking for. haven't tried yet myself, might trick:

app.route(path='/', method='get', callback=func, apply=[auth, mako_view('index.html')]) 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -