Skip to content

Instantly share code, notes, and snippets.

@snaka
Created April 30, 2012 03:47
Show Gist options
  • Select an option

  • Save snaka/2555272 to your computer and use it in GitHub Desktop.

Select an option

Save snaka/2555272 to your computer and use it in GitHub Desktop.
GAEでのカスタムテンプレートタグの本体とそれを利用する側のソースコード例
<html>
<body>
{% hello %}
</body>
</html>
# custom template tag user
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
template.register_template_library('tag_library.my_tags')
class MainHandler(webapp.RequestHandler):
def get(self):
path = os.path.join(os.path.dirname(__file__), "hello.html")
self.response.out.write(template.render(path, {}))
app = webapp.WSGIApplication([('/', MainHandler)],
debug=True)
# custom template tag
from google.appengine.ext.webapp import template
register = template.create_template_register()
@register.simple_tag
def hello():
return "Hello GAE world!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment