Nice!
Thanks for sharing this, Zagfai.

On Friday, 13 July 2012 06:06:47 UTC-3, Zagfai Kwong wrote:
>
> Something I wrote days ago...
>
> inside an app... 
>
>>         # make topics for udata
>>         udata[ 'topics' ] = []
>>         tmp = client.get.statuses__friends_timeline( count = 50, page = 1 
>> )
>>         for topic in tmp['statuses']:
>>             retweet = {}
>>             try:
>>                 retweet = { \
>>                     'screen_name': 
>>  topic['retweeted_status']['user']['screen_name'],
>>                     'text'       :  topic['retweeted_status']['text'],
>>                     }
>>             except: pass
>>             udata[ 'topics' ].append({ \
>>                 'screen_name':  topic['user']['screen_name'],
>>                 'avatar_url':   topic['user']['profile_image_url'],
>>                 'text':         topic['text'],
>>                 'thumbnail_pic':topic.get('thumbnail_pic'),
>>                 'retweet':      retweet,
>>                 })
>>         return render.index( udata )
>
>
>
> index.html
>
>> $def with (user)
>
> <!DOCTYPE HTML>
>> <html>
>> <head>
>>     <meta http-equiv="content-type" content="text/html; charset=utf-8">
>>     <title>$user['screen_name'] 的微新報</title>
>>     <style type="text/css">
>>     body {
>>     background-color:#b0c4de;
>>     }
>>     div {
>>         display: block;
>>     }
>>     </style>
>> </head>
>> <body>
>>     <div id="head">
>>       <img src="$(user['avatar_url'])" />
>>         $user['screen_name'] : $user['lats_weibo']
>>     </div>
>>     <div id="topic_container">
>>     $for topic in user['topics']:
>>         <dl class="$loop.parity">
>>             <dt id="avatar">
>>                 <span><img src="$(topic['avatar_url'])" /></span> 
>>                 <span>
>>                     $topic['screen_name'] :$topic['text']
>>                     <img src="$(topic['thumbnail_pic'])" />
>>                 </span>
>>             </dt>
>>             </dd>
>>             $if topic['retweet']:
>>                 <dd id="retweet">
>>                     $topic['retweet']['screen_name'] 
>> :$topic['retweet']['text']
>>                 </dd>
>>         </dl>
>>     </div>
>> </body>
>> </html>
>
>
> Tomas Schertel於 2012年7月13日星期五UTC+8上午4時53分10秒寫道:
>>
>> I'd like to know how you guys pass values to a template.
>> If I have a form with, let's say, 30 fields on it, it would be ugly and 
>> complicated to have a "def with" statement with 30 variables.
>> I think a good way to solve this is passing a dictionary to my template. 
>> Isn't it?
>> Who can show me what do you use in this situation?
>>
>> Thanks.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/webpy/-/Oy-tag5VmiwJ.
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