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


#1

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> and TextPattern <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

Documentation:
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

Enjoy!


John L.
http://wiseheartdesign.com/


#2

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.


#3

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


John


#4

On 5/1/06, John W. Long 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> and TextPattern <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/