I am pleased to announce the immediate release of Radius 0.5.1.
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…). Radiant CMS <www.radiantcms.org> currently uses
Radius in its unique templating system.
This is a bug-fix release.
From the change log:
0.5.1
- Fixed a problem with parsing quotes where a single tag preceding a
double tag would consume the start tag of the double tag if both
contained attributes
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!