# \[ANN\] Radius 0.0.1 -- Powerful Tag-Based Templates

**URL:** <https://www.ruby-forum.com/t/ann-radius-0-0-1-powerful-tag-based-templates/59358>\
**Category:** Ruby\
**Created:** [May 3, 2006, 6:58pm UTC](https://www.ruby-forum.com/t/ann-radius-0-0-1-powerful-tag-based-templates/59358 "2006-05-03T18:58:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [May 3, 2006, 6:58pm UTC](https://www.ruby-forum.com/t/ann-radius-0-0-1-powerful-tag-based-templates/59358/1 "2006-05-03T18:58:21Z")

</div>

I am pleased to announce the immediate release of Radius 0.5.0.

Radius is a small, but powerful tag-based template language for Ruby  
inspired by the template languages used in MovableType  
\<[www.movabletype.org](http://www.movabletype.org)\> and TextPattern \<[www.textpattern.com](http://www.textpattern.com)\>. It uses  
tags similar to XML, but can be used to generate any form of plain text  
(HTML, e-mail, etc…).

This release is much more feature complete than previous releases with  
it’s own domain language and support for nested tags.

From the change log:

0.5.0

- Created a DSL for tag definitions (introducing a DSL makes this  
version of Radiant incompatible with the last). The DSL has the  
following features:
  - full support for nested tags
  - global and local tag variables
  - Contexts can now be defined dynamically (instead of being  
subclassed)
  - see the QUICKSTART for more info

- Many refactorings of the library and unit tests.
- Changed the license to the MIT-LICENSE.
- Updated documentation to reflect the changes.
- Updated the version number to reflect the maturity of the code  
base.

Download:  
[http://rubyforge.org/frs/?group\_id=1262](http://rubyforge.org/frs/?group_id=1262)

Documentation:  
[http://radius.rubyforge.org](http://radius.rubyforge.org)

Instalation:  
% gem install --remote radius

A small example:

require ‘radius’

# Define tags on a context that will be available to a template:

context = Radius::Context.new do |c|  
c.define\_tag ‘hello’ do  
‘Hello world’  
end  
c.define\_tag ‘repeat’ do |tag|  
number = (tag.attr[‘times’] || ‘1’).to\_i  
result = ‘’  
number.times { result \<\< tag.expand }  
result  
end  
end

# Create a parser to parse tags that begin with ‘r:’

parser = Radius::Parser.new(context, :tag\_prefix =\> ‘r’)

# Parse tags and output the result

puts parser.parse(“A small example:\n” +  
‘\<r:repeat times=“3”\>\* \<r:hello /\>!\n\</r:repeat\>’)

Output:

A small example:

- Hello world!
- Hello world!
- Hello world!

Learn more by reading the Quick Start guide:  
[http://radius.rubyforge.org/files/QUICKSTART.html](http://radius.rubyforge.org/files/QUICKSTART.html)

Enjoy!

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

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [May 3, 2006, 6:58pm UTC](https://www.ruby-forum.com/t/ann-radius-0-0-1-powerful-tag-based-templates/59358/2 "2006-05-03T18:58:57Z")

</div>

If this is release 0.5.0, then why does the subject line say 0.0.1? was  
this  
just a mistake? or am I missing something here?

Ciao,  
–Tyler P.

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [May 3, 2006, 6:59pm UTC](https://www.ruby-forum.com/t/ann-radius-0-0-1-powerful-tag-based-templates/59358/3 "2006-05-03T18:59:03Z")

</div>

Yah, sorry. Copy error. The correct version is 0.5.0.

–  
John

---

<div class="post-metadata">

**Author:** ![John\_WSLong](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@John\_WSLong](https://www.ruby-forum.com/u/John_WSLong)\
**Post date:** [August 18, 2006, 11:00pm UTC](https://www.ruby-forum.com/t/ann-radius-0-0-1-powerful-tag-based-templates/59358/4 "2006-08-18T23:00:29Z")

</div>

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

> I am pleased to announce the immediate release of Radius 0.5.0.
> 
> Radius is a small, but powerful tag-based template language for Ruby  
> inspired by the template languages used in MovableType  
> \<[www.movabletype.org](http://www.movabletype.org)\> and TextPattern \<[www.textpattern.com](http://www.textpattern.com)\>. It uses  
> tags similar to XML, but can be used to generate any form of plain text  
> (HTML, e-mail, etc…).

Hi, I d/l the current release 0.5.0 and some things didn’t work. The  
docs say that the default tag prefix is ‘radius’, but the default when  
I created it was nil. This then only works for tags like this:

\<:hello name=“john” /\>

Also the Quickstart guide has an example using just

c=Context.new

But you need:

c=Radius::Context.new

Cool lib tho. I’d previously been using MasterView [1] and there are  
some similarities. But I like the way I can create individual contexts  
and reuse them here. I can use them in helper libs, inside RHTML  
templates, etc. I’m attempting a larger DSL around this.

One thing, I don’t get is how to get these to automatically get called  
from within rails. I guess, you have to just use erb’s \<%=  
parser.parse '\<r:my\_tag /\> %\>

Is there a way in Rails to intercept the default render dispatch with  
your own thing? There is the block parameter to render, but does that  
do anything. Should there be a specific file extension, say file.rad  
which would fire up Radius to do the parsing? MV does this somehow,  
but it is dark magic.

Ed  
[1] MasterView - Rails-optimized (x)html friendly template engine  
[http://masterview.org/](http://masterview.org/)
