Here's an extension I wrote a year ago recently repackaged to work with
my Conditional Tags extension. First of all many will notice that, some
parts of it behave eerily like Manuel's Parameterized Snippets
extension. I'm really not interested in sowing confusion -- he and I
have already started talking and we'll see if we can't find a nice blend
of the two before it's all done.
In the meantime, I wanted to release this anyway since:
* It demonstrates nicely how to create your own evaluators for use
Conditional Tags
* It does offer some features that his extension does not
* I'd like feedback from the community as to usefulness and the best
approach. (As with most of the stuff I release publicly, I'd like
this to be something that is generally useful for the community as
a whole and not some niche piece of code).
GitHub link: http://github.com/SwankInnovations/radiant-variables-extension
Check out the readme and the descriptions for the tags, but in a
nutshell this extension:
* Creates a <r:set_vars> tag that lets you declare variables/values
globally. Values are cast as a number, boolean, nil or string.
* Augments <r:snippet> so that any extra attributes become variable
declarations (just like Parameterized Snippets). These variables
are only available within the context of the tag (just like
Parameterized Snippets). Values are cast as with <r:set_vars>.
* Augments <r:content> just like <r:snippet>. Wow, Parameterized
Page Parts.
* Creates a <r:puts> tag to let you render your variable values
elsewhere. (Personally I'm thinking of moving this into
Conditional Tags so its utility wouldn't be limited to just
variables -- we'll see).
* Creates an evaluator for ConditionalTags so that you can do things
like:
<r:if cond=" vars[myVar] exists? " > or
<r:unless cond=" children.count gte vars[someVar] " >
Enjoy.
-Chris
_______________________________________________
Radiant mailing list
Post: Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant