Webapp2 custom tags

ε祈祈猫儿з 提交于 2019-12-12 13:14:52

问题


I am migrating from webapp1 to webapp2 and from python 2.5 to python2.7 I had some custom tags I used with

webapp.template.register_template_library('common.templatetags')

and registered with:

from google.appengine.ext.webapp import template
register = template.create_template_register()

and the corresponding decorator and everything else worked fine

now I need to use webapp2 which does not have template.register.....

I tried doing it this way : http://www.john-smith.me/Tag/webapp2 but it didn't work

thanks


回答1:


solved by using add_to_builtins()

from django.template.loader import add_to_builtins

add_to_builtins('myapp.templatetags.mytagslib')


来源:https://stackoverflow.com/questions/10618551/webapp2-custom-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!