Careful, though -- you don't want to allow untrusted users to provide
template code, as it will execute any Python that is inserted.
Anthony
On Wednesday, March 20, 2013 3:37:21 PM UTC-4, Lamps902 wrote:
>
> Thanks, Anthony. I think this is exactly what I was asking about. I'll try
> it out now.
>
>
> On Wednesday, March 20, 2013 1:39:21 PM UTC-5, Anthony wrote:
>>
>>
>>> stored_code = "<a href='{{=request.vars.the_link}}'>{{=request.vars.
>>> the_link}}</a>"
>>>
>>> It sounds like there might be better options, but if for some reason you
>> need to execute stored template code as above, I think you can do something
>> like:
>>
>> from gluon.template import render
>> html = render(stored_code, context=globals())
>>
>> Specifying context=globals() should ensure that the request object and
>> any other global objects are available for reference within the template
>> code. You could also specify a dictionary or Storage object including just
>> the objects you need:
>>
>> from gluon.template import render
>> stored_code = "<a href='{{=the_link}}'>{{=the_link}}</a>"
>> html = render(stored_code, context=request.vars))
>>
>> Anthony
>>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.