= Vars If This extension combines two sets of tags which could, ultimately, each be made into their own extensions. Since this is just a proof-of-concept, I have kept them together for simplicity. == CONDITIONALS == (/lib/if_tags.rb) == The purpose of these tags is to consolidate conditional statements. We already have , , and . And just the other day John authorized a new . Then there are the extension developers -- cranking out their own tags. The benefits to this method are: * Provide consistency and simplify things for users (instead of having to remember that the tag has no attributes, but the has a 'matches' attribute and has 'part'). All existing tag behavior can be rolled into one -- with one common set of rules. * Keep the tag namespace clean(prevent all those tags cluttering the user's documentation up). * Make it (almost) trivial to add additional tests for core items without having to create things like or . * Expand the range of conditions that can be evaluated. For instance, the tag of today merely tests for the existence of the specified page part. Instead, we can test whether: or, * Allow extension developers hook into the core of conditionals by exposing their own values to test. I have seen several extensions that have needed to create their own custom tags. In the spirit of keeping things DRY and simplifying things for users (See bullet 1), this extension allows other extensions to add their elements to conditions. (NOT YET IMPLEMENTED) The result, three tags: ... ... For more info on usage, see the 'available tags' documentation within the Radiant page view. == VARIABLES == (/lib/var_tags.rb) == Vars, is a simple set of tags to declare variables. The variable scope is determined by the tag -- a single tag declares globally, and a container tag, only for the local scope of the container. Of course this is all useless without some way to retrieve the variables. Some refactoring led to making the 'get' tag part of the conditionals piece (above). This way the same code that gets variables for output, gets them for testing conditionals. And extension writers can make use of this common 'get' to render their extension's values Finally, I modified the tag to allow variables to be declared there too. Technically, this isn't necessary since the following two are equal: So, my feelings are mixed on keeping this snippet mod. But the benefit to all this is that snippets can behave more like rails helpers. They become simple functions where values can be passed to another Radiant element and then acted upon there. For an example, see the end of the next section. == EXAMPLE USAGE == The 'if/unless' conditionals allow for the replacement/simplification of several existing tags like: becomes, becomes, becomes, but that's not the main point. This also adds new possibilities with: The 'get' function replaces/simplifies other existing tags like: becomes becomes OK, so that didn't really simplify much (though it does clean up the number of tags floating around and encourages users to organize their thoughts about title and slug). It does make it easy to get new items, though -- like publish date, or a render a custom value from an extension. Speaking of a custom extension value, when combined with the 'puts' functionality, the Vars piece allows you to set and get variables. SNIPPET (named 'link'): " class="" > RESULT: Some example link text == ISSUES == 1.) Compound Symbols - This is the area that needs the most help. I wanted a way to expose Radiant elements and, also, extension elements to the user (via puts and if/unless). The way the user refers to these elements is using a convention I call Compound Symbols. Currently there are three problems to be solved with them: a.) I'm only sort of OK with the syntax. Currently it is a simple notation: ObjectRouting[ItemToEval] The idea is that the ObjectRouting gives the tag enough info to figure out who gets to resolve the ItemToEval (i.e. is it a page element, or something from an extension) and then it hands off the evaluation to that piece. I'm toying with changing the notation to just page.title or children.count and leaving the [] for things that really need addl params (examples include: page.part[page part name] or page.date[format: %l %p, %b %d, %Y, for: now] I'm still looking for ideas. I don't mind having to dance around with the code so long as it works elegantly to the user and at least semi- elegantly to the extension developer. b.) So, whatever the notation, I need a way to access Radiant Elements via these symbols. Currently, it's semi-hard coded (I allow title, url, slug, and breadcrumb). I'm ok with that but it doesn't seem very extensible. What if a user extends the page model and wants to access those new fields, or what if they just want to expose more than I do. Seems kinda klunky to have to go in an edit my tags directly. c.) Here's the big one. What if a user creates their own extension with their own values that they want to expose. How do they do that via their extension? For example my stuff should be in a separate extension and there should be no sign of how to evaluate vars[my variable] in the conditionals stuff. But how can I do that - allow extension developers to "hook" into the evaluation code? 2.) Testing - I have created several test tags to allow me to expose private routines used by my tags. This is a bogus solution because they are visible in production. I'd like to have those tags AND their subroutines available to my testing but I have NO idea how to pull that off. Guess I could just stick to black box testing. 3.) Code Improvements - not only do I believe that "more eyes" helps, but I don't really claim to be a coder. There's got to be a better way to do some of this stuff.