On Jan 30, 2009, at 4:07 PM, Kris Wallsmith wrote:
>
> Hi Jacob,
>
> I'm not sure I understand what you're suggesting. Can the same thing
> be accomplished using the second argument of the slot() helper?
> (available since 1.1)
>
> <?php slot('body_id', 'about') ?>
> <?php slot('flash', 'Success message goes here') ?>
Yes, it can. The link I included does just that and adds a helper to
see if the slot is defined and includes it if so.
Perhaps it's just semantic sugar but content_for makes more sense to
me than slot. I'd always associated slots with components. Not for
lightweight content. The example linked also adds a default if the
slot's content isn't defined, which is nice for body IDs or other
persistent elements that you occasionally need to override..
>
>
> Kris
>
> On Jan 30, 12:54 pm, Jacob Coby <[email protected]> wrote:
>> One of the things I really like about Ruby on Rails is the
>> content_for
>> helper. It makes templating easier and keeps the presentation logic
>> in the presentation layer.
>>
>> For example:
>>
>> layout.hml.erb:
>>
>> <html>
>> <head>...</head>
>> <body id="<%= yield(:body_id) %>">
>>
>> <div class="flash"><%= yield(:flash) %></div>
>> <div class="content><%= yield %></div>
>> </body>
>> </html>
>>
>> Then in the module view.html.erb:
>>
>> <% content_for :body_id do %>about<% end %>
>> <% content_for :flash do %>Success message goes here<% end %>
>>
>> -- regular view content here --
>>
>> each of the content_for calls stuffs its content into the yield
>> statement from the layout file.
>>
>> Would there be any interest in adding something similar to symfony?
>> You can already kind of emulate it using the slot() / end_slot()
>> helpers
>> (seehttp://blog.mirthlab.com/2008/08/06/giving-your-body-tag-some-kick/)
>> , but it would be nice to have dedicated functions for this in the
>> core. I wouldn't mind coding up something for 1.3 if there is
>> interest.
>>
>> --
>> Jacob Coby
> >
--
Jacob Coby
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony developers" 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/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---