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/''>Ruby</a></td> <td>matz</td> </tr><tr class=''even''> <td><a href=''http://www.perl.com/''>perl</a></td> <td>Larry Wall</td> </tr><tr class=''odd''> <td><a href=''http://www.python.org/''>python</a></td> <td>Guido van Rossum</td> </tr> </table>
> > <table border=''1''> > <tr><th>name</th><th>author</th></tr> > <tr class=''odd''> > <td><a href=''http://www.ruby-lang.org/''>Ruby</a></td> > <td>matz</td> > </tr><tr class=''even''> > <td><a href=''http://www.perl.com/''>perl</a></td> > <td>Larry Wall</td> > </tr><tr class=''odd''> > <td><a href=''http://www.python.org/''>python</a></td> > <td>Guido van Rossum</td> > </tr> > </table>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? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
2005/12/7, Vivek Krishna <krishna.vivek-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> 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
On Wed, 7 Dec 2005, Vivek Krishna wrote:>> <table border=''1''> >> <tr><th>name</th><th>author</th></tr> >> <tr class=''odd''> >> <td><a href=''http://www.ruby-lang.org/''>Ruby</a></td> >> <td>matz</td> >> </tr><tr class=''even''> >> <td><a href=''http://www.perl.com/''>perl</a></td> >> <td>Larry Wall</td> >> </tr><tr class=''odd''> >> <td><a href=''http://www.python.org/''>python</a></td> >> <td>Guido van Rossum</td> >> </tr> >> </table> > > 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 -- ==============================================================================| ara [dot] t [dot] howard [at] noaa [dot] gov | all happiness comes from the desire for others to be happy. all misery | comes from the desire for oneself to be happy. | -- bodhicaryavatara ==============================================================================_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
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, ara.t.howard-32lpuo7BZBA@public.gmane.org <ara.t.howard-32lpuo7BZBA@public.gmane.org> wrote:> On Wed, 7 Dec 2005, Vivek Krishna wrote: > > >> <table border=''1''> > >> <tr><th>name</th><th>author</th></tr> > >> <tr class=''odd''> > >> <td><a href=''http://www.ruby-lang.org/''>Ruby</a></td> > >> <td>matz</td> > >> </tr><tr class=''even''> > >> <td><a href=''http://www.perl.com/''>perl</a></td> > >> <td>Larry Wall</td> > >> </tr><tr class=''odd''> > >> <td><a href=''http://www.python.org/''>python</a></td> > >> <td>Guido van Rossum</td> > >> </tr> > >> </table> > > > > 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 > -- > ==============================================================================> | ara [dot] t [dot] howard [at] noaa [dot] gov > | all happiness comes from the desire for others to be happy. all misery > | comes from the desire for oneself to be happy. > | -- bodhicaryavatara > ==============================================================================> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- - Ramin http://www.getintothis.com/blog
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 john-mason.shackelford-uJfvbxoDSvxBDgjK7y7TUQ@public.gmane.org http://pearsonedmeasurement.com
On 7-dec-2005, at 13:20, Vivek Krishna wrote:> <table border=''1''> > <tr><th>name</th><th>author</th></tr> > <tr class=''odd''> > <td><a href=''http://www.ruby-lang.org/''>Ruby</a></td> > <td>matz</td> > </tr><tr class=''even''> > <td><a href=''http://www.perl.com/''>perl</a></td> > <td>Larry Wall</td> > </tr><tr class=''odd''> > <td><a href='' http://www.python.org/''>python</a></td> > <td>Guido van Rossum</td> > </tr> > </table> > > 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