Skip to content
Browse files

Merge pull request #30 from stevekochscience/master

fixed formatting on template_tricks.md
  • Loading branch information...
2 parents 299d3a4 + 9329f0c commit 7e1bcece994bdd95391737e7b4b3e92467446fdb @aaronsw aaronsw committed Aug 1, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 template_tricks.md
View
12 template_tricks.md
@@ -10,17 +10,21 @@ title: template tricks
Test the rendering of a template.py template
def renderTemplate(templatename,*args,**kw):
- '''quick way to test a template.py template''' import template
+ '''quick way to test a template.py template'''
+ import template
if not "." in templatename:
- templatename = templatename + ".tmpl" obj = template.Template(open(templatename).read())
+ templatename = templatename + ".tmpl"
+ obj = template.Template(open(templatename).read())
return obj(*args,**kw)
print renderTemplate("homepage", now=time.ctime())
If your template takes a dict or a storage, then you can just
set global values and let those get passed in:
- username = "User" lastvisit = "yesterday" print renderTemplate("results", store=web.Storage(globals()))
+ username = "User"
+ lastvisit = "yesterday"
+ print renderTemplate("results", store=web.Storage(globals()))
---
@@ -54,4 +58,4 @@ you forget the space, you'll get this error from template.py:
myElement = $$('elementID');
----
+---

0 comments on commit 7e1bcec

Please sign in to comment.
Something went wrong with that request. Please try again.