# \[ANN\] Amrita2 1.9.6

**URL:** <https://www.ruby-forum.com/t/ann-amrita2-1-9-6/49661>\
**Category:** Ruby\
**Created:** [December 7, 2005, 9:54am UTC](https://www.ruby-forum.com/t/ann-amrita2-1-9-6/49661 "2005-12-07T09:54:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tnakajima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@tnakajima](https://www.ruby-forum.com/u/tnakajima)\
**Post date:** [December 7, 2005, 9:54am UTC](https://www.ruby-forum.com/t/ann-amrita2-1-9-6/49661/1 "2005-12-07T09:54:24Z")

</div>

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/](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 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](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.

| name | author |
| --- | --- |
| [Ruby](http://www.ruby-lang.org/) | matz |
| [perl](http://www.perl.com/) | Larry Wall |
| [python](http://www.python.org/) | Guido van Rossum |

---

<div class="post-metadata">

**Author:** ![tnakajima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@tnakajima](https://www.ruby-forum.com/u/tnakajima)\
**Post date:** [December 7, 2005, 1:22pm UTC](https://www.ruby-forum.com/t/ann-amrita2-1-9-6/49661/2 "2005-12-07T13:22:38Z")

</div>

> ```
> <td><a href='http://www.python.org/'>python</a></td>
> <td>Guido van Rossum</td>
> 
> ```

I fail to get the point… RoR already has a template system .all views  
are  
templates…so whats the point of this thing? besides why cant I use a  
for  
loop in the view on some variable set in the controller to generate  
these  
table rows?

---

<div class="post-metadata">

**Author:** ![tnakajima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@tnakajima](https://www.ruby-forum.com/u/tnakajima)\
**Post date:** [December 7, 2005, 3:17pm UTC](https://www.ruby-forum.com/t/ann-amrita2-1-9-6/49661/3 "2005-12-07T15:17:00Z")

</div>

2005/12/7, Vivek K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I fail to get the point… RoR already has a template system .all views are  
> templates…so whats the point of this thing? besides why cant I use a for  
> loop in the view on some variable set in the controller to generate these  
> table rows?

Yes, RoR separates view from model completely. But ERB template  
contains both VIEW PRESENTATION and VIEW LOGIC. Amrita2 and some other  
template system like Kwartz, XTemplate, SikiTemplate, misen, try to  
separate VIEW PRESENTATION from VIEW LOGIC.

[http://www.rubygarden.org/ruby?HtmlTemplates](http://www.rubygarden.org/ruby?HtmlTemplates)

There are cases at which ERB is not enough

- VIEW LOGICs must be tested separately
- Multi language (international) VIEW PRESENTATIONs share same VIEW  
LOGICs
- want to design or check VIEW PRESENTATION staticaly without RoR  
environment

And Amrita2 makes both VIEW PRESENTATION and VIEW LOGIC more  
decralative than ERB. I think Decralative code is easier to write,  
understand, modify, test than procedural code in ERB template.

I think ERB is good for default template system for RoR. But we need  
alternative and that’s what plugin is for.

–  
Taku Nakajima

---

<div class="post-metadata">

**Author:** ![tnakajima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@tnakajima](https://www.ruby-forum.com/u/tnakajima)\
**Post date:** [December 7, 2005, 5:35pm UTC](https://www.ruby-forum.com/t/ann-amrita2-1-9-6/49661/4 "2005-12-07T17:35:39Z")

</div>

On Wed, 7 Dec 2005, Vivek K. wrote:

> > ```
> > <td>Guido van Rossum</td>
> > 
> > ```
> 
> I fail to get the point… RoR already has a template system .all views are  
> templates…

not so - all views are view-controllers: erb mixes the two and is an  
ugly wart  
on an otheriwse clean mvc architechture imho.

> so whats the point of this thing? besides why cant I use a for loop in the  
> view on some variable set in the controller to generate these table rows?

for loops are relatively benign - but the second you put someother kind  
of  
logic into the view you’ve broken mvc. erb makes this easy to do and  
most of  
the rails projects (only 4 or 5 admittedly) i’ve read do this to varying  
degree. breaking mvc isn’t bad by definition - just like global  
variables are  
not bad by definition.

i’ve been waiting a long time to see rails/amrita integration and am  
confident  
that the same people who prefer normalized databases, postgresql to  
mysql,  
ruby to perl, object access control, data encapuslation and orthoganl  
design  
in general with grow to prefer it.

kind regards.

-a

---

<div class="post-metadata">

**Author:** ![tnakajima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@tnakajima](https://www.ruby-forum.com/u/tnakajima)\
**Post date:** [December 7, 2005, 7:50pm UTC](https://www.ruby-forum.com/t/ann-amrita2-1-9-6/49661/5 "2005-12-07T19:50:28Z")

</div>

Not to mention cool tools: [http://webpub.narucy.com/index.en.html](http://webpub.narucy.com/index.en.html).

John-Mason Shackelford

Software Developer  
Pearson Educational Measurement

2510 North Dodge St.  
Iowa City, IA 52245  
ph. 319-354-9200x6214  
removed\_email\_address@domain.invalid  
[http://pearsonedmeasurement.com](http://pearsonedmeasurement.com)

---

<div class="post-metadata">

**Author:** ![tnakajima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@tnakajima](https://www.ruby-forum.com/u/tnakajima)\
**Post date:** [December 7, 2005, 8:02pm UTC](https://www.ruby-forum.com/t/ann-amrita2-1-9-6/49661/6 "2005-12-07T20:02:52Z")

</div>

On 7-dec-2005, at 13:20, Vivek K. wrote:

> ```
> <td>Guido van Rossum</td>
> 
> ```
> 
> I fail to get the point… RoR already has a template system .all  
> views are templates…so whats the point of this thing? besides why  
> cant I use a for loop in the view on some variable set in the  
> controller to generate these table rows?

Please, let’s not get into the same argument again. Let’s say so -  
templating systems are different, and serve different needs. It’s  
very good that Rails supports view drivers and that we now have 3  
different ways to do templating in Rails.

–  
Julian ‘Julik’ Tarkhanov  
me at julik.nl

---

<div class="post-metadata">

**Author:** ![tnakajima](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/aca169/32.png) [@tnakajima](https://www.ruby-forum.com/u/tnakajima)\
**Post date:** [December 7, 2005, 6:45pm UTC](https://www.ruby-forum.com/t/ann-amrita2-1-9-6/49661/7 "2005-12-07T18:45:09Z")

</div>

I have been waiting for this ever since day 1 of using Rails. Just  
like how I hate writing scriptlets in JSP’s and putting PHP code in my  
HTML. I really didn’t like the use of Ruby code in my view templates.

Thanks for making and sharing this plugin! I really hope one of these  
templating systems become part of the framework.

On 12/7/05, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > >
> 
> that the same people who prefer normalized databases, postgresql to mysql,  
> | comes from the desire for oneself to be happy.  
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–

- Ramin  
[http://www.getintothis.com/blog](http://www.getintothis.com/blog)
