There are some things you can do better:

1) use triple quotes:

stilo1 = """style="background-image:url("/init/static/li_dash.gif");"
"""

2) store the style, not "style='...'"

stilo1 = "background-image:url('/init/static/li_dash.gif');"

3) use helpers

stilo1 = "background-image:url('/init/static/li_dash.gif');"
with
{{=DIV(day,_class="container",_style=stilo1)}}

The latter will take care of proper escaping for you. XML should be a
last resource helper. Try avoid it.




On May 5, 7:07 am, salbefe <salb...@gmail.com> wrote:
> Hello,
>
> I need to generate inside a div tag the style attribute dinamically,
> something like:
>
> <div class="container" style="background-color:#ded;">2</div>
>
> for some situations the following code works well:
>
> [...]
> elif day == current_day:
>         stilo = 'style=\"font-weight:bold;\"'
> pass
> [...]
>
> <div class="column">
>         <div class="container" {{=XML(stilo)}}>{{=XML(day)}}</div>
> </div>
>
> The problem comes when I try to do the following
>
> [...]
> elif day == current_day:
>     stilo1 = 'style=\"background-image:url("/init/static/li_dash.gif");
> \"'
> pass
> [...]
>
> <div class="column">
>         <div class="container" {{=XML(stilo)}}>{{=XML(day)}}</div>
> </div>
>
> I have try to put "\" before each "/" too and does not work. Is not
> rendered well. Anyone knows the right way to insert this kind of code
> in python?? I come from the PHP world :(
>
> Thanks!

Reply via email to