# Can radiant tags replace simple XSLT?

**URL:** <https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659>\
**Category:** Radiant CMS\
**Created:** [July 5, 2007, 7:34pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659 "2007-07-05T19:34:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave4c03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@dave4c03](https://www.ruby-forum.com/u/dave4c03)\
**Post date:** [July 5, 2007, 7:34pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659/1 "2007-07-05T19:34:53Z")

</div>

Can radiant tags replace simple XSLT? For example, how would I create a  
 tag that wrapped n tags?

---

<div class="post-metadata">

**Author:** ![dave4c03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@dave4c03](https://www.ruby-forum.com/u/dave4c03)\
**Post date:** [July 5, 2007, 7:42pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659/2 "2007-07-05T19:42:54Z")

</div>

Yes and no. There are many available tags for manipulating content,  
but they primarily manipulate existing content in the CMS, i.e. pages,  
page-parts, snippets, and layouts. Can you give an example of the  
source you want to transform and the result of its transformation?

Of course, there is always the possibility for a custom extension that  
processes XML and XSLT using libxml2/libexslt. That would be kind of  
neat, in fact.

Sean

---

<div class="post-metadata">

**Author:** ![dave4c03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@dave4c03](https://www.ruby-forum.com/u/dave4c03)\
**Post date:** [July 5, 2007, 7:57pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659/3 "2007-07-05T19:57:56Z")

</div>

I am trying to avoid XSLT if possible, I would like to leave XSLT behind  
me:)

For a simple example, let us say a page contained the following radiant  
tags:

And I wanted it to generate the following html:

| xxx | xxx |

Can custom radiant tags be constructed to do this?

---

<div class="post-metadata">

**Author:** ![dave4c03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@dave4c03](https://www.ruby-forum.com/u/dave4c03)\
**Post date:** [July 5, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659/4 "2007-07-05T20:07:57Z")

</div>

Personally, I agree with Martin F. on this matter. See

> **[bliki: MovingAwayFromXslt](https://www.martinfowler.com/bliki/MovingAwayFromXslt.html)**
>
> a bliki entry for MovingAwayFromXslt

Unless speed is critical I will simplicity whenever possible.

---

<div class="post-metadata">

**Author:** ![dave4c03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@dave4c03](https://www.ruby-forum.com/u/dave4c03)\
**Post date:** [July 5, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659/5 "2007-07-05T20:01:56Z")

</div>

just curious: isn’t XSLT faster than any radiant template parser?  
XSLT is bad only in one thing - when it goes to dynamic data,  
you can’t change input XML on fly but XSLT parser is really good idea  
for template language.

---

<div class="post-metadata">

**Author:** ![dave4c03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@dave4c03](https://www.ruby-forum.com/u/dave4c03)\
**Post date:** [July 5, 2007, 9:18pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659/6 "2007-07-05T21:18:08Z")

</div>

Hi Dave,

If you want to get away from XSLT but still want to keep this XML  
format,  
you could always make an extension that defines a filter and keep your  
XML  
data in a separate page part (so that the filter is only applied to that  
data). There’s an example filter in the trunk:

[http://dev.radiantcms.org/radiant/browser/trunk/extensions/sass\_filter](http://dev.radiantcms.org/radiant/browser/trunk/extensions/sass_filter)

and another extension that adds a filter on the 3rd party extension page  
(Maruku Filter I think?).

In your filter class, you would define a “filter(text)” method that  
takes  
the input text and outputs your final html. So in that method you could  
run  
over the XML with REXML or Hpricot (or any other library) and handle the  
transformation.

Or the filter could run an XSLT transformation if one were so inclined.

-Andrew

---

<div class="post-metadata">

**Author:** ![dave4c03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@dave4c03](https://www.ruby-forum.com/u/dave4c03)\
**Post date:** [July 5, 2007, 10:26pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659/7 "2007-07-05T22:26:21Z")

</div>

Dave,

I agree with the other responses, but here’s a sample of what you  
might be able to do:

\<r:table\>  
\<r:column /\>  
\<r:column /\>  
\</r:table\>

* * *

tag ‘table’ do |tag|  
returning String.new do |output|  
output \<\< “

”  
output \<\< “” \<\< tag.expand \<\< “”  
output \<\< “

|
| |

”  
end  
end

tag ‘table:column’ do |tag|  
“

\n xxx\n”  
end

Obviously that’s very rough and just an outline of what you might want  
to do. If your end users are HTML/CSS proficient, then just use HTML!  
Radiant is nice in that it gets out of your way in terms of design.

When you need something programmatic, then consider using Radius tags.

Sean

---

<div class="post-metadata">

**Author:** ![dave4c03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@dave4c03](https://www.ruby-forum.com/u/dave4c03)\
**Post date:** [July 5, 2007, 10:16pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659/8 "2007-07-05T22:16:18Z")

</div>

Thanks, there is no doubt in my mind that Haml is impressive! If I was  
the  
only person involved I suspect that I would prefer that route.

However, I have to deal with people who only talk html and css.  
Therefore,  
the simplest solution is to embed radiant tags into the html (if I can  
get  
them to do the job).

---

<div class="post-metadata">

**Author:** ![dave4c03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/839c29/32.png) [@dave4c03](https://www.ruby-forum.com/u/dave4c03)\
**Post date:** [July 5, 2007, 10:53pm UTC](https://www.ruby-forum.com/t/can-radiant-tags-replace-simple-xslt/108659/9 "2007-07-05T22:53:25Z")

</div>

I actually haven’t tried HAML and SASS yet either – the reason I linked  
to  
the SassFilter was that it’s an example of an extension that implements  
a  
filter.  
I may not be understanding your use-case correctly, but who or what is  
producing this XML? And why could they/it just use standard HTML  
tables?

I guess no matter what you could use either the filter or radius tag  
solution depending on what fits your situation best.

-Andrew
