Hi folks, After some scratching around in the source for Markaby I think I've finally cobbled together a Markaby filter for Radiant that works in a decent manner. The following Markaby code
h1 {r.title!} p do text("Today's date is ") r.date! br text("You are ") r.author! end p do r.random do r.option "snap" r.option "crackle" r.option "pop" end end r.snippet :name=>"contact_details" p do r.navigation :urls=>"Home: /;Projects: /projects;About Us: /about" do r.normal{a(:href=>"<r:url/>"){r.title!}} r.between "::" r.here{em{r.title!}} end end gets transformed into the following (tidied up) HTML: <h1>Markaby Example</h1> <p>Today's date is Wednesday, August 02, 2006<br/> You are Administrator</p> <p>snap</p> <p>15 Main St<br/> Anytown<br/> USA</p> <p> <em>Home</em>:: <a href="/projects">Projects</a>:: <a href="/about">About Us</a> </p> There are a few things to be aware of when using the filter. Because of the dynamic nature of Radiant's tags and the fact new ones could be defined depending on the behaviour of the page in certain cases we need to explicitly indicate that the tag is 'finished'. In cases where a tag takes an argument or block (like 'r.between "::"' or 'r.random do...end') this is deduced automatically but in cases where it isn't, for instance if you just want to generate '<r:date/>' then you need to either give an empty argument (r.date "") or use the much more elegant r.date! (which I strongly suggest). Another thing is that because tags are generated in the order that they are executed 'a :href=>r.url' will not generate correct html because the 'r.ur'l will be evaluated before the 'a'. In this case you're going to have to use 'a :href=>"<r:url/>"'. This seems to be the only type of case where this seems to pop up so I hope it isn't a major nuisance. The filter also has the 'r' radius tag prefix hardcoded so hopefully this won't change in the future. Is the tag prefix avaiable in some constant? One more note is that the filter swaps the order in which the filter and radius parser work. Hopefully that doesn't kill other filters. A very big disclaimer I have not tested this beyond my own simple tests so I would not suggest you use it in a production system. I appreciate any suggestions or bugfixes that would help it work better. Farrel
markaby_filter.rb
Description: Binary data
_______________________________________________ Radiant mailing list Radiant@lists.radiantcms.org http://lists.radiantcms.org/mailman/listinfo/radiant