You cannot use the template language inside a string. You can use inside a template file.
content_block = XML("h1> Some Title </h1> <img src='{{=URL('static','images/python.gif')}}>", should be content_block = XML('<h1>Some Title</h1> <img src="%s" />' % URL('static','images/python.gif')) On Monday, 22 July 2013 00:20:07 UTC-5, shapova...@gmail.com wrote: > > Hi! > > Know that I missing something obvious here, but still: > > I store parts of page to be displayed in db, in html code, and return it > to view, so content from db is in content_block var: > > def get_block(): > [some other code] > content_block = XML("h1> Some Title </h1> <img > src='{{=URL('static','images/python.gif')}}>", sanitize=False > return dict(form=form, content_block = content_block) > > > view: > {{extend 'layout.html'}} > {{=form}} > {{block content_block}} {{=content_block}} {{end}} > > but it turns out that URL helper is not executed when passed to view in an > variable, so I get <img src="{{=URL(" static',images="" python.gif')}}=""> > in the browser. > Probably the view gets constructed (parsed) before vars passed to it are > added. > > So, what is the best way to pass HTML parts with helpers (for IMG, A, etc) > to view in an variable and still use the advantages of URL helper? > I don't like the idea of statically setting links in html parts. > > > -- --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.