author | Tero Marttila <terom@fixme.fi> |
Mon, 16 Feb 2009 01:40:26 +0200 | |
changeset 71 | 0162c2b21dc5 |
parent 70 | add1c1f7831c |
permissions | -rw-r--r-- |
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
""" |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
Template handler |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
""" |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
5 |
from mako import exceptions, util |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
6 |
from mako.runtime import Context |
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
from mako.template import Template |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
8 |
import mako.lookup |
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
|
46 | 10 |
from qmsk.web import http, helpers |
26
9d3beac1b196
remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
21
diff
changeset
|
11 |
|
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
# path to template files |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
TEMPLATE_DIR = "templates" |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
|
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
# path to cached templates |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
CACHE_DIR = "cache/templates" |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
|
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
# template file extension |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
19 |
TEMPLATE_EXT = "tmpl" |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
20 |
|
70
add1c1f7831c
make TemplateError a normal Exception, not a http.ResponseError
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
21 |
class TemplateError (Exception) : |
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
""" |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
Raised by the template module functions |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
""" |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
25 |
|
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
26 |
pass |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
27 |
|
71 | 28 |
def fmt_mako_exception () : |
29 |
""" |
|
30 |
Returns a string containing the Mako-ized error traceback (so that it includes the template data) |
|
31 |
""" |
|
32 |
||
33 |
return exceptions.text_error_template().render() |
|
34 |
||
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
35 |
class TemplateLoader (mako.lookup.TemplateLookup) : |
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
""" |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
37 |
Our own specialization of mako's TemplateLookup |
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
""" |
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
40 |
def __init__ (self, path, fileext=TEMPLATE_EXT, _helper_class=helpers.Helpers, **env) : |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
41 |
""" |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
42 |
Initialize to load templates located at path, with the given file extension. |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
43 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
44 |
The given Helpers class is used to provide the helper methods |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
45 |
|
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
46 |
The given **env list is supplied to every template render |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
47 |
""" |
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
48 |
|
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
49 |
# store |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
50 |
self.path = path |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
51 |
self.fileext = fileext |
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
52 |
self.helper_class = _helper_class |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
53 |
self.env = env |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
54 |
|
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
55 |
# build the TemplateLookup |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
56 |
super(TemplateLoader, self).__init__(directories=[path], module_directory=CACHE_DIR) |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
57 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
58 |
def _render (self, tpl, env, params) : |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
59 |
""" |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
60 |
Render the given template with given env/params, returning the output as a unicode string, or raising a TemplateError |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
61 |
""" |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
62 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
63 |
# build our Helpers class |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
64 |
helpers = self.helper_class() |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
65 |
|
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
66 |
# build the context from our env, and params |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
67 |
ctx = dict( |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
68 |
h = helpers, |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
69 |
) |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
70 |
ctx.update(env) |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
71 |
ctx.update(params) |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
72 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
73 |
# the buffer to use for unicode output |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
74 |
buf = util.FastEncodingBuffer(unicode=True) |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
75 |
|
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
76 |
# the context to use |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
77 |
context = Context(buf, **ctx) |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
78 |
|
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
79 |
# bind our helper |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
80 |
helpers._bind_ctx(context) |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
81 |
|
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
82 |
try : |
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
83 |
# render template |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
84 |
tpl.render_context(context) |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
85 |
|
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
86 |
# a template may render other templates |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
87 |
except TemplateError : |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
88 |
raise |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
89 |
|
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
90 |
except : |
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
91 |
# raise a TemplateError with the details |
71 | 92 |
raise TemplateError("tpl=%r, params=%r: %s" % (tpl, params, fmt_mako_exception())) |
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
93 |
|
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
94 |
else : |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
95 |
# return the unicode data |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
96 |
return buf.getvalue() |
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
97 |
|
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
98 |
def lookup (self, name) : |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
99 |
""" |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
100 |
Looks up a template based on the bare "name", which does not include the path or file extension |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
101 |
""" |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
102 |
|
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
103 |
try : |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
104 |
return self.get_template("%s.%s" % (name, self.fileext)) |
8
0ce1f471e9d7
and it works, a lot better than before
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
105 |
|
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
106 |
except : |
71 | 107 |
raise TemplateError("name=%r: %s" % (name, fmt_mako_exception())) |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
108 |
|
40 | 109 |
def render (self, name, **params) : |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
110 |
""" |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
111 |
Render a template, using lookup() on the given name |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
112 |
""" |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
113 |
|
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
114 |
return self._render(self.lookup(name), self.env, params) |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
115 |
|
40 | 116 |
def render_to_response (self, name, **params) : |
117 |
""" |
|
118 |
Render a template, returning a http.Response object |
|
119 |
""" |
|
120 |
||
121 |
return http.Response(self.render(name, **params)) |
|
122 |
||
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
123 |
def load (self, path) : |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
124 |
""" |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
125 |
Loads a template from a specific file |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
126 |
""" |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
127 |
|
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
128 |
try : |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
129 |
return Template(filename=path, module_directory=CACHE_DIR) |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
130 |
|
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
131 |
except : |
71 | 132 |
raise TemplateError("path=%r: %s" % (path, fmt_mako_exception())) |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
133 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
134 |
def render_file (self, path, **params) : |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
135 |
""" |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
136 |
Render a template, using load() on the given path. No global environment vars are defined for the render. |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
137 |
""" |
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
138 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
139 |
return self._render(self.load(path), dict(), params) |
32
be954df4f0e8
move layout.tmpl to sites/www.qmsk.net
Tero Marttila <terom@fixme.fi>
parents:
26
diff
changeset
|
140 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
141 |
def render_template (self, template, **params) : |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
142 |
""" |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
143 |
Render the given template object. No global environment vars are defined for the render. |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
144 |
""" |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
40
diff
changeset
|
145 |
|
50
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
146 |
return self._render(template, dict(), params) |
e4fbf480fbee
change templates to remove all class/staticmethods, make Helpers a context-aware class, and fix defaults/URLIntegerType bugs in URLTree
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
147 |