sivakrishna.m
Joined: 01 Jan 2008 Posts: 160 Location: Narsipatnam
|
Posted: Mon Sep 21, 2009 8:51 am Post subject: Radius Gem For powerful Tag-Based Templates |
|
|
Radius is a Tag Based template language for Ruby on rails for movable types and text pattern types, and also it uses tag similar to xml.
For Instance,
if you want to print the context , like simple text information, you have to create an object for Context class for a radius module like below
cont = Radius::Context.new do |c|
c.define_tag 'siva' do
'siva'
end
c.define_tag 'repeat' do |t|
num = (t.attr['times'] || '1').to_i
res = ''
num.times{res << t.expand}
res
end
end
then create a parser for created tags
par = Radius::Parser.new(cont,:tag_prefix => 'r')
then the result will be follows
puts par.parse(%{nice example : <r:repeat times='5'>*<r:siva/>!\n</r:repeat>})
output:
=======
Nice example
* siva
* siva
* siva
* siva
* siva
Download the latest version of Radius can be found on RubyForge:
http://rubyforge.org/projects/radius/
or install the gem
> gem install --remote radius |
|