Aitor Garay-Romero-3 wrote: > > 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 agree. My original goal was to create something that would fit within the core values - simplify a common task in a easily used way. This one gets to be a challenge because it reaches a little deeper into programming than some other tags. Aitor Garay-Romero-3 wrote: > > 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 direction I went was with declaring variables rather than purely passing parameters. I then enhanced <r:snippet to let you declare variables at the same time (I have a standard to also just <r:store vars="myVar1: Chris; myVar2: 47; myVar3: false">). The idea here was that you could access those values in a snippet but also elsewhere in the same page, or within other contexts. You could even set a variable within a snippet and then use it back within the calling page. That's why I named it 'vars' instead of 'params'. Overall, I like the simplicity of your modified <r:snippet>. But I also feel like it is too limited. I also have an application that needs variables outside the scope of snippets. I wonder if any of the core guys have an opinion here? John? Anyone? Aitor Garay-Romero-3 wrote: > > 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> > I prefer my format with a single attribute for all the variables/parameters for no particularly exceptional reason. I'll have to think more on your idea -- it's got merit. (Though it's nice to not deal with any reserved attribute names). I *really* like the idea of adding content to the snippet tag that is consumed by the snippet (you used the <r:body> tag). One thing that you didn't address here is that once you start dealing with variable/parameters, conditionals quickly become necessary. Often you want to respond one way or another within the snippet depending on the value (or lack of value) stored in a variable/parameter. So I ended up creating generalized <r:if> and <r:unless> tags -- to give the user a protected way to respond to these variables/parameters (but also to respond to items like page.title or page.part[partName]). Do you have any suggestions here? Aitor Garay-Romero-3 wrote: > > 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. > It's the security stuff that prevents me from touching backdoor. And it's not just that I have users that I don't trust with the full power of ruby -- I don't trust me. A bit like giving a kid a rocket launcher for Christmas - sure it keeps the bullies away but you're asking for trouble ;-). -Chris -- View this message in context: http://www.nabble.com/Radiant-Best-Practice-tf4472903.html#a13282850 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
