2011/1/29 Remco <[email protected]>:
> Hey web.py group!
>
> I have a Templetor question. In a template, I want to do something
> like:
>
> E-mail address: <input name="email" $(if 'email' in tvars:
> value="$tvars['email']")/><br/>
> (So when 'email' is set in a dict tvars, then value="$tvars['email']"
> should be added to the input-field)
>
> The only way I can get this done is by placing the if-statement on a
> new line, like:
>
> E-mail address: <input name="email" \
> $if 'email' in tvars:
>    value="$tvars['email']"\
>>
>
> , but this is the way I like it :(
>
> Is there a way to do it in one line in the template itself?

You can do it like this:

$cond('email' in tvars, "value=" + tvars['email])

You need to add web.cond to template globals to be able to do this.

Anand

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to