On Thu, Oct 2, 2008 at 9:46 AM, Joe Van Dyk <[EMAIL PROTECTED]> wrote: > On Wed, Oct 1, 2008 at 7:26 PM, Jordan Isip <[EMAIL PROTECTED]> wrote: >> Hi All, >> >> What is the best approach to generating the following HTML? >> >> <div class='section'> >> <div class='section-header'> >> #{ title } >> </div> >> <div class='section-content'> >> <r:yield/> >> </div> >> </div> >> >> I would like to call it with something like: <r:snippet >> title="News">News</r:snippet>. Basically just using the snippet tag but I >> would like to be able to pass the title as a param. > > This is a good question, but I don't have an answer for you.
Nevermind, I do. From http://www.ruby-forum.com/topic/125007 Usage: To call the snippet: <r:snippet name='test-snippet' title='Joe Rules'> Content is in here </r:snippet> The snippet: <div> <h2> <r:var name='title' /> </h2> <p> Content: <r:yield /> </p> </div> The code: # TODO Put into extension desc %{ crazy hack for getting params in snippets } tag "snippet:var" do |tag| var = tag.attr['name'] || nil if var.blank? %{<b>NO ATTR SPECIFIED</b>} else ret_val = nil content = tag.context.instance_variable_get(:@tag_binding_stack).detect{ |slot| slot.name == "snippet"} if !content.blank? ret_val = content.attr[var] || nil if ret_val.blank? %{<b>COULDN'T FIND ATTR #{var}</b>} else %{#{ret_val}} end else %{<b>ERROR IN GETTING CONTENT</b>} end end end _______________________________________________ Radiant mailing list Post: Radiant@radiantcms.org Search: http://radiantcms.org/mailing-list/search/ Site: http://lists.radiantcms.org/mailman/listinfo/radiant