Forum: Ruby Amrita2 1.9.6

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
takunakajima (Guest)
on 2005-12-07 11:06
(Received via mailing list)
Amrita2 is a XML/HTML template library for Ruby.  I released a new
version 1.9.6 as BETA1 for 2.0. Get it from

 http://amrita2.rubyforge.org/

I reduced undocumented features and refactored much to prepare the
comming stable release. And ..

* added gemspec and make it Rails plugin
* simplified the ERB processing feature
* new feature for setting two attributes (like class='odd' and
 class='even') alternately

Now Amrita2 template can contain ERB source in it.

       <table border='1'>
         <tr><th>name</th><th>author</th></tr>
         <tr id='languages'>
           <td><![CDATA[
              <a href='<%= $_.url %>'><%= $_.name %></a>
           ]]></td>
           <td id='creator'></td>
         </tr>
       </table>

CDATA in <td> element will be evaluated as many times as number of
'languages' data. And each item will be set to '$_' before ERB
evaluating. See this page for detail.

 How to use Amrita2 with Ruby On Rails
 http://amrita2.rubyforge.org/Rails.html

And this method setup Template to insert two attributes alternately.

 def languages_setup_template(template)
   tmpl = Amrita2::TemplateText.new(template)
   tmpl.use_erb(binding)
   tmpl.element_option[:languages] =  { :mv_attr=> { :class=>%w(odd
even)
} }
   tmpl
 end

This template produces output like this.

<table border='1'>
 <tr><th>name</th><th>author</th></tr>
 <tr class='odd'>
   <td><a href='http://www.ruby-lang.org/'
<http://www.ruby-lang.org/%27>
>Ruby</a></td>
   <td>matz</td>
 </tr><tr class='even'>
   <td><a href='http://www.perl.com/' <http://www.perl.com/%27>
>perl</a></td>
   <td>Larry Wall</td>
 </tr><tr class='odd'>
   <td><a href='http://www.python.org/' <http://www.python.org/%27>
>python</a></td>
   <td>Guido van Rossum</td>
 </tr>
</table>
gsinclair (Guest)
on 2005-12-08 05:54
(Received via mailing list)
Taku Nakajima wrote:
> Amrita2 is a XML/HTML template library for Ruby.  I released a new
> version 1.9.6 as BETA1 for 2.0.

Great.  Any chance you could release Amrita as a gem?

Thanks,
Gavin
takunakajima (Guest)
on 2005-12-08 16:27
(Received via mailing list)
> Great.  Any chance you could release Amrita as a gem?

I have uploaded gem of Amrita2 to rubyforge. So, you can install
Amrita2 by gem now. Just type

  # gem install amrita2

I will upload gem of Amrita 1.0.X with next release of Amrita2.
This topic is locked and can not be replied to.