On Saturday, September 8, 2012 12:14:16 PM UTC-4, lyn2py wrote:
>
> Thanks Anthony for stepping up.
>
> I have a views file, it has quite a chunk of html in it. If I could put it 
> in the controller, I would, but it's quite hefty.
>
> I have about 15 fields, displayed via SQLFORM, just a simple 
> form = SQLFORM(db.table)
>
> I want to insert a {{include html_file}} in the middle, and I've tried
> form[0].insert(7,'{{include "template.html"}}')
>

Try:

form[0].insert(7,
    XML(response.render('path/to/template.html', dict(var1='something'),othervar
='something else')))

response.render() will render a template and return the HTML as a string. 
You should wrap the response in XML() so the text doesn't get escaped. The 
path to the template should be relative to the /views folder. The second 
argument can be a dict -- the items in the dict will be available as 
variables in the view environment (just like when a controller function 
returns a dict). You can also add additional keyword arguments, which will 
also get added to the view environment.

Anthony

-- 



Reply via email to