It appears that $var statement can be multiline, so there is not much need 
in my proposal. The only difference is that it appends content to defined 
section so content from multiple $content_for blocks can be included in one 
section.  



On Monday, November 26, 2012 2:38:17 PM UTC+4, Andrey Kuzmin wrote:
>
> I'm sad no one really finds this useful. I mostly work on the front-end 
> and really need this template functionality.
>
> On Sunday, November 25, 2012 5:50:38 PM UTC+4, Andrey Kuzmin wrote:
>>
>> Hello
>>
>> I've had some troubles when child templates need to provide some content 
>> for the parent templates. 
>>
>> My first approach was setting $var in child template, and access it from 
>> parent template. But this approach has obvious limitation: you cannot 
>> provide more complex content than just one string (yes you can by setting 
>> $var to sub-sub-template output, but this is not flexible).
>>
>> Instead of this I implemented a special content_for code block, that 
>> outputs contents to web.ctx, so then parent templates may output them.
>>
>> Child template:
>>
>>     $content_for("header"):
>>>         <p>Some content for header</p>
>>
>>
>> Parent template:
>>
>>     $:content_for("header")
>>
>>
>>
>> I've put the code in this issue 
>> https://github.com/webpy/webpy/issues/192#issuecomment-10693336
>> My first implementation was dirty, but then I found out how to make it 
>> nicer by hiding functionality in generated template code
>>
>> I'm not sure if this feature can make its way in web.py code, but I'd 
>> like to get some feedback from web.py users.
>>
>>
>>

-- 
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/-/ycF_YKRq8OUJ.
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