diff options
| author | Chris McDonough <chrism@agendaless.com> | 2008-07-19 01:32:40 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2008-07-19 01:32:40 +0000 |
| commit | c42a5844612d8033016d3a4b9c0726ae5bde12c9 (patch) | |
| tree | 3becf07daaafd7b3cc5829dbc2c5ba6339dbb878 /docs/narr/templates.rst | |
| parent | 4dc2f81b4d9ef4610cd6a9f21faed81966ed8c9a (diff) | |
| download | pyramid-c42a5844612d8033016d3a4b9c0726ae5bde12c9.tar.gz pyramid-c42a5844612d8033016d3a4b9c0726ae5bde12c9.tar.bz2 pyramid-c42a5844612d8033016d3a4b9c0726ae5bde12c9.zip | |
Yup.
Diffstat (limited to 'docs/narr/templates.rst')
| -rw-r--r-- | docs/narr/templates.rst | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/docs/narr/templates.rst b/docs/narr/templates.rst index 294bff8db..4b74ab652 100644 --- a/docs/narr/templates.rst +++ b/docs/narr/templates.rst @@ -21,8 +21,8 @@ faster, of course, is the zen of ``repoze.bfg``. Given a template named ``foo.html`` in a directory in your application named "templates", you can render the template in a view via:: - from repoze.bfg.template import render_template - render_template('templates/foo.html', foo=1, bar=2) + from repoze.bfg.template import render_template_to_response + return render_template_to_response('templates/foo.html', foo=1, bar=2) You can also wire up page templates via ZCML: @@ -47,21 +47,22 @@ Like ZPT, an XSLT template is loaded once and re-used between requests. Given a template ``foo.xsl`` in the templates directory, you can render an XSLT as follows:: - from repoze.bfg.template import render_transform + from repoze.bfg.template import render_transform_to_response from lxml import etree node = etree.Element("root") - render_transform('templates/foo.xsl', node) + return render_transform_to_response('templates/foo.xsl', node) -As shown, the second argument to ``render_transform`` is the element -(and children) that you want as the top of the data for the XSLT. +As shown, the second argument to ``render_transform_to_response`` is +the element (and children) that you want as the top of the data for +the XSLT. You can also pass XSLT parameters in as keyword arguments:: - from repoze.bfg.template import render_transform + from repoze.bfg.template import render_transform_to_response from lxml import etree node = etree.Element("root") value1 = "'app1'" - render_transform('templates/foo.xsl', node, param1=value1) + return render_transform_to_response('templates/foo.xsl', node, param1=value1) This would then assign 'app1' as the value of an ``<xsl:param name="param1"/>`` parameter in the XSLT template. |
