I like the idea of parametrized snippets. I hope that the core team
considers this for future releases, i believe that the idea is simple and
fits in the philosophy of Radiant.
I would suggest to add the parameters individually to the <r:snippet>
tag, and to allow a body to be defined:
<r:snippet name="rounded-box" class="whatever" bg-color="blue">
This is a parametrized snippet...
</r>
The "name" attribute is reserved. The user is free to use any other,
and they will be passed to the snippet code, may be with a <r:param> and
<r:body> tag:
<div class="<r:param name="class"> rounded"
style="background-color:<r:param name="bg-color">" >
<r:body>
</div>
Backdoor 0.3.0 has a <r:tag> and <r:erb_tag> that can be used as
parametrized snippets, but it has the known security implications.
/AITOR
On 10/18/07, Chris Parrish <[EMAIL PROTECTED]> wrote:
>
>
> Sorry for such a late response here. Just reading through posts I'd
> missed
> while away and came across this.
>
>
> Aitor Garay-Romero-3 wrote:
> >
> > I see the problem.
> >
> > It would be nice to allow parametrization of snippets, but right
> > now that it's not possible. This behavior can be implemented with a
> > custom extension though.
> >
> > /AITOR
> >
>
> This need is one of the main reasons that drove me to create my
> Vars/Conditionals Extension. In my case I had a series of wrapper divs
> that
> made up rounded boxes on my site. There were several variations, and some
> had different content inside and/or unique classes that needed to be
> applied. It seemed wrong to have 30 different snippets that were all
> variations on the same theme.
>
> My goal was to make snippets more like rails helpers or partials -- which
> meant that you needed to be able to pass (and then process) arguments.
>
> I even wrote a special modification to the <r:snippet> tag for this very
> reason (though it's not technically necessary)
>
> In the body you'd add:
> <r:snippet name="box" vars="content:text to fill" />
> <r:snippet name="box" vars="content:second text to fill" />
>
> Then in the snippet, you'd add:
> <div class="foo">....
> <r:puts value_for="vars[content]" />
> </div>
>
>
> If you want to get fancy, you can also pass multiple, optional parameters,
> like:
> <r:snippet name="box" vars="content: 'text to fill'; id: myId" />
>
> and:
> <div class="foo"<r:if cond="vars[id]> id="<r:puts value_for="vars[id]"
> />"</r:if>>
> <r:puts value_for="vars[content]" />
> </div>
>
> In this case your snippet adds the id tag to your div IF you include a
> value
> for it.
>
>
> Feel free to download the extension and try it out:
>
> http://swankinnovations.svnrepository.com/svn/open/radiant/extensions/vars_if/trunk/
>
> Hope this helps!
>
> -Chris
>
>
> On 9/18/07, Andrea Otto <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I'd like to know how can I use radiant at the best...
> >
> > For example: I have a Homepage with a lot of boxes with same graphic.
> > How can I deploy this?
> >
> > My first thought was creating something like this in the body:
> >
> > <r:snippet name="box">text to fill</r:snippet>
> > <r:snippet name="box">second text to fill</r:snippet>
> >
> > and create a snippet like this:
> > <div class="foo">....
> > <r:content>
> > </div>
> >
> > I know that it can't be done... but it is my first use logic...
> >
> > So... How can I do it?
> >
> > My only working solution is to create a lot of childs page, all with a
> > "mytext" part, put <r:snippet name="box"> in each body, create a snippet
> > like this:
> > <div class="foo">....
> > <r:content part="mytext">
> > </div>
> >
> > and include all of my childs_box in the homepage with <r:child:each>
> >
> > Is it the right solution? Or there's a more pratic and fast modus
> > operandi, like the first I exposed?
> > --
> > 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
> >
> --
> View this message in context:
> http://www.nabble.com/Radiant-Best-Practice-tf4472903.html#a13265682
> Sent from the Radiant - User mailing list archive at Nabble.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