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/