It's interesting. I would change some names you use, but overall the
idea is nice. Now, it's up to Radius developers to decide if it's worth
including this feature. I believe so.
Thanks for sharing!
/AITOR
On Dec 13, 2007 6:58 AM, Witter Cheng <[EMAIL PROTECTED]> wrote:
> Aitor Garay-Romero wrote:
> > I like the idea of parametrized snippets.
>
> Here is how I have implemented this idea.
>
>
> In the tag plugin:
>
> define_tag "snippet:pageattr" do |tag|
> attr_to_get = tag.attr['attr_to_get'] || nil
> if attr_to_get.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[attr_to_get] || nil
> if ret_val.blank?
> %{<b>COULDN'T FIND ATTR #{attr_to_get}</b>}
> else
> %{#{ret_val}}
> end
> else
> %{<b>ERROR IN GETTING CONTENT</b>}
> end
> end
> end
>
>
> The snippet tag in the page:
>
> <r:snippet name="a_snippet" attr_one="hello" attr_two="goodbye" />
>
>
> The pageattr tags in the snippet:
>
> <r:pageattr attr_to_get="attr_one" />
> <r:pageattr attr_to_get="attr_two" />
>
>
> This will display "hello" and "goodbye" in the snippet.
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Radiant mailing list
> Post: [email protected]
> Search: http://radiantcms.org/mailing-list/search/
> Site: http://lists.radiantcms.org/mailman/listinfo/radiant
>
_______________________________________________
Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant