# Markaby Filter for Radiant

**URL:** <https://www.ruby-forum.com/t/markaby-filter-for-radiant/101156>\
**Category:** Radiant CMS\
**Created:** [August 3, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/markaby-filter-for-radiant/101156 "2006-08-03T14:23:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [August 3, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/markaby-filter-for-radiant/101156/1 "2006-08-03T14:23:16Z")

</div>

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:

# Markaby Example

Today's date is Wednesday, August 02, 2006  
You are Administrator

snap

15 Main St  
Anytown  
USA

_Home_:: [Projects](https://www.ruby-forum.com/projects):: [About Us](https://www.ruby-forum.com/about)

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

---

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [August 3, 2006, 2:23pm UTC](https://www.ruby-forum.com/t/markaby-filter-for-radiant/101156/2 "2006-08-03T14:23:35Z")

</div>

Farrel L. wrote:

> 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?

The tag prefix is not likely to change. You do have access to it inside  
a behavior on @parser.tag\_prefix, but I don’t think there is an easy way  
to access it with a text filter.

Nifty idea for a text filter, BTW.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [August 3, 2006, 2:24pm UTC](https://www.ruby-forum.com/t/markaby-filter-for-radiant/101156/3 "2006-08-03T14:24:45Z")

</div>

On 03/08/06, John W. Long [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> John L.  
> [http://wiseheartdesign.com](http://wiseheartdesign.com)

I actually use Textile myself as a filter, but this was an itch that I  
wanted to scratch.

Farrel

---

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [August 3, 2006, 7:22pm UTC](https://www.ruby-forum.com/t/markaby-filter-for-radiant/101156/4 "2006-08-03T19:22:37Z")

</div>

On Aug 3, 2006, at 2:34 AM, Farrel L. wrote:

> > to access it with a text filter.  
> > Farrel  
> > From my perspective (new to rails, not new to web apps) markaby has  
> > allowed me to basically ditch HTML and focus completely on CSS and  
> > Rails. With a well tuned reusable stylesheet (may I suggest the one  
> > I’ve been using for a Rails project, [http://fullahead.org/work/](http://fullahead.org/work/)  
> > lazydays/) I can now create just about any layout I desire. This is  
> > such a huge boon for my anal retentive styling eyeballs.

Looking to the future, if a drupal or phpnuke (god forbid) user were  
to enter the RoR domain exclusively through Radiant, I would expect  
the “wow” over magic markaby, than clunky radius. Heck, up until  
recently I thought radius was something that was internal to Radiant,  
not a separate project.

Viva la markaby.

Caylan
