Several options:
*Pure HTML:*
{{some code}}
*Python string formatting:*
{{='{%s}' % '{some code}'}}
*Python function (defined in model or module):*
def wrap(code):
return '{{%s}}' % code
and then in the view:
{{=wrap('some code')}}
*Javascript:*
<script>
jQuery(function() {
jQuery('.code').html(function(index, oldhtml) {
return '{'+'{'+oldhtml+'}}'
})
})
</script>
<span class='code'>some code</span>
*Read from external file:*
{{import os}}
{{=open(os.path.join(request.folder, 'views/myview.html'), 'rb').read()}}
You can also take advantage of the web2py CODE() helper to get nice code
formatting of the template code. See
http://web2py.com/books/default/chapter/29/5#Built-in-helpers.
Anthony
On Thursday, April 26, 2012 8:44:43 AM UTC-4, LMisi wrote:
>
> Hi
>
> I would like to show some view's code in my web2py page. But the first
> {{}} symbols in the html generate execution instead of pure displaying
> (showing).
> I can generate decent html code from my python files, and shows in my
> page, but views...
>
> Thanks
>