By putting your code in a string passed as an argument to XML, you are
saying you want that string to be displayed as opposed to executed; the
fact that it happens to be code is irrelevant.
If you want the code to run on the server, creating the page to be
displayed, you can just put it in your view.
If you want the code to be executed in the browser, you are out of luck.
- Scott
On Sunday, March 24, 2019 at 2:29:41 PM UTC-4, yng wrote:
>
> Hi Guru's.
>
> I'm new to web2py and web development in general.
> Hope somebody can help me.
>
> I want to inject a html markup with python code at run time.
>
> controller:
> def test():
> dynamicHtml = XML('{{for x in range(2):}}{{=x}}hello<br />{{pass}}')
> return locals()
>
>
> view: test.html
> {{=dynamicHtml}}
>
>
> The output is this:
> {{for x in range(10):}}{{=x}}hello<br />{{pass}}
>
> This is what I'm expecting:
> 1hello
> 2hello
>
> Hope my explanation is clear.
> What would be the best solution to implement this?
>
> Thanks advance,
> yng
>
>
>
>
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.