From c42a5844612d8033016d3a4b9c0726ae5bde12c9 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 19 Jul 2008 01:32:40 +0000 Subject: Yup. --- docs/narr/introduction.rst | 4 ++-- docs/narr/templates.rst | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'docs') diff --git a/docs/narr/introduction.rst b/docs/narr/introduction.rst index 2d63a2659..a2b925265 100644 --- a/docs/narr/introduction.rst +++ b/docs/narr/introduction.rst @@ -405,7 +405,7 @@ views.py A views.py module might look like so:: from webob import Response - from repoze.bfg.template import render_template + from repoze.bfg.template import render_template_to_response def my_hello_view(context, request): response = Response('Hello from %s @ %s' % ( @@ -414,7 +414,7 @@ A views.py module might look like so:: return response def my_template_view(context, request): - return render_template('templates/my.pt', name=context.__name__) + return render_template_to_response('templates/my.pt', name=context.__name__) models.py ~~~~~~~~~ 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 ```` parameter in the XSLT template. -- cgit v1.2.3