[ANN] Amrita2 1.9.6


#1

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

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.

name author
Ruby matz
perl Larry Wall
python Guido van Rossum

#2
<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?


#3

2005/12/7, Vivek K. 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

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


#4

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


#5

Not to mention cool tools: 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


#6

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


#7

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 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