Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fixed formatting on template_tricks.md #30

Merged
merged 1 commit into from

2 participants

@stevekochscience

currently, it's showing up without linefeeds on webpy.org
I fixed it so it looks like what I think is correct
I'm using gedit with "replace tabs with spaces", so I'm not sure
why my previous commit had messed-up tabs/spaces. Let me know how
to do it better for next time.

@stevekochscience stevekochscience fixed formatting of python code for testing template rendering
currently, it's showing up without linefeeds on webpy.org
I fixed it so it looks like what I think is correct
I'm using gedit with "replace tabs with spaces", so I'm not sure
why my previous commit had messed-up tabs/spaces. Let me know how
to do it better for next time.
9329f0c
@stevekochscience

I am poking around on other pages that I also don't understand...but that have similar formatting issues (possibly). Let me know if this correction was good and I'll fix those too as I see them. E.g. http://webpy.org/quick_vhosting_hack

@aaronsw aaronsw merged commit 7e1bcec into webpy:master
@aaronsw
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 1, 2012
  1. @stevekochscience

    fixed formatting of python code for testing template rendering

    stevekochscience authored
    currently, it's showing up without linefeeds on webpy.org
    I fixed it so it looks like what I think is correct
    I'm using gedit with "replace tabs with spaces", so I'm not sure
    why my previous commit had messed-up tabs/spaces. Let me know how
    to do it better for next time.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 4 deletions.
  1. +8 −4 template_tricks.md
View
12 template_tricks.md
@@ -10,9 +10,11 @@ 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())
@@ -20,7 +22,9 @@ Test the rendering of a template.py template
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');
----
+---
Something went wrong with that request. Please try again.