Markaby Filter for Radiant

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:: About Us

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

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

On 03/08/06, John W. Long [email protected] wrote:


John L.
http://wiseheartdesign.com

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

Farrel

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs