Okay, for grins, I hacked (rudimentary) support for Amrita into ActionView. However, in doing so, I discovered a few things that I dislike about Amrita, and I was wondering if anyone else (any experts here?) could indicate whether there are work arounds, or whether this is just the way it is with Amrita: 1. It uses the "id" attribute. I know you can force it to leave the id''s in the output, instead of removing them, but even so it makes it very hard to use the id''s effectively in DHTML. I would rather see something like "oid", or "rwcid" (a la Tapestry). 2. It doesn''t, apparently, expand nested objects? Assuming an AR Book, which belongs_to Author, and an array of books: <tr id="books"> <td id="author"> <span id="name"></span> </td> </tr> Where the author''s name should be, it is putting the result of Author#to_s, i.e. "#<Author:@!#$@A@#$!@>". :( 3. Amrita::ExpandByMember. It seems to me that (especially with Rails) this is just one more hoop to jump through. All AR''s need to have this mixed in by default, and so do any other objects that you happen to pass in. Seems like this ought to be a feature of every object, by default. 4. Amrita uses symbols as the hash keys. Rails uses strings. This means that you have to explicitly convert the assigns arrays so that the keys use symbols instead of strings, and doing this on ever render is not going to be cheap (especially when there are lots of values). Can anyone recommend another templating engine, similar to Amrita, that might not suffer under the limitations I described above? I''m still not convinced that there is real value in using a templating engine other than ERb, but I''m willing to try one for a little while to see what benefits might be gained. - Jamis -- Jamis Buck jamis_buck-8Bzd4dk9+oo@public.gmane.org http://jamis.jamisbuck.org ------------------------------ "I am Victor of Borge. You will be assimil-nine-ed."
Seems to me what would be more beneficial than another templating engine is a component model/engine. I''ve been developing in Tapestry now for well over a year and a half and when I do a little Rails I really miss such a great component model. Have you looked at Iowa or Borges? Jamie ----- Original Message ----- From: "Jamis Buck" <jamis_buck-8Bzd4dk9+oo@public.gmane.org> To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Tuesday, February 15, 2005 3:20 PM Subject: [Rails] Amrita as templating engine> Okay, for grins, I hacked (rudimentary) support for Amrita into > ActionView. > > However, in doing so, I discovered a few things that I dislike about > Amrita, and I was wondering if anyone else (any experts here?) could > indicate whether there are work arounds, or whether this is just the > way it is with Amrita: > > 1. It uses the "id" attribute. I know you can force it to leave the > id''s in the output, instead of removing them, but even so it makes > it very hard to use the id''s effectively in DHTML. I would rather > see something like "oid", or "rwcid" (a la Tapestry). > > 2. It doesn''t, apparently, expand nested objects? Assuming an AR > Book, which belongs_to Author, and an array of books: > > <tr id="books"> > <td id="author"> > <span id="name"></span> > </td> > </tr> > > Where the author''s name should be, it is putting the result of > Author#to_s, i.e. "#<Author:@!#$@A@#$!@>". :( > > 3. Amrita::ExpandByMember. It seems to me that (especially with Rails) > this is just one more hoop to jump through. All AR''s need to have > this mixed in by default, and so do any other objects that you > happen to pass in. Seems like this ought to be a feature of every > object, by default. > > 4. Amrita uses symbols as the hash keys. Rails uses strings. This > means that you have to explicitly convert the assigns arrays so > that the keys use symbols instead of strings, and doing this on > ever render is not going to be cheap (especially when there are > lots of values). > > Can anyone recommend another templating engine, similar to Amrita, > that might not suffer under the limitations I described above? I''m > still not convinced that there is real value in using a templating > engine other than ERb, but I''m willing to try one for a little while > to see what benefits might be gained. > > - Jamis > > -- > Jamis Buck > jamis_buck-8Bzd4dk9+oo@public.gmane.org > http://jamis.jamisbuck.org > ------------------------------ > "I am Victor of Borge. You will be assimil-nine-ed." > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On 15:48 Tue 15 Feb , Jamie Orchard-Hays wrote:> Seems to me what would be more beneficial than another templating engine is > a component model/engine. > > I''ve been developing in Tapestry now for well over a year and a half and > when I do a little Rails I really miss such a great component model. > > Have you looked at Iowa or Borges?I haven''t actually. I''ll wander over that direction and see what I can see. Thanks for the tip. - Jamis -- Jamis Buck jamis_buck-8Bzd4dk9+oo@public.gmane.org http://jamis.jamisbuck.org ------------------------------ "I am Victor of Borge. You will be assimil-nine-ed."
Here''s an interesting blog thread I just read concerning these: http://jroller.com/comments/lsd?anchor=lightweight_web_application_platform_subversion ----- Original Message ----- From: "Jamis Buck" <jamis_buck-8Bzd4dk9+oo@public.gmane.org> To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Sent: Tuesday, February 15, 2005 3:54 PM Subject: Re: [Rails] Amrita as templating engine> On 15:48 Tue 15 Feb , Jamie Orchard-Hays wrote: >> Seems to me what would be more beneficial than another templating engine >> is >> a component model/engine. >> >> I''ve been developing in Tapestry now for well over a year and a half and >> when I do a little Rails I really miss such a great component model. >> >> Have you looked at Iowa or Borges? > > I haven''t actually. I''ll wander over that direction and see what I can > see. Thanks for the tip. > > - Jamis > > -- > Jamis Buck > jamis_buck-8Bzd4dk9+oo@public.gmane.org > http://jamis.jamisbuck.org > ------------------------------ > "I am Victor of Borge. You will be assimil-nine-ed." > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Jamis Buck wrote:> Can anyone recommend another templating engine, similar to Amrita, > that might not suffer under the limitations I described above? I''m > still not convinced that there is real value in using a templating > engine other than ERb, but I''m willing to try one for a little while > to see what benefits might be gained.In an earlier message I recommended the template language which is based on Amrita and integrated into Cerise (http://cerise.rubyforge.org/). Cerise Templates. http://cerise.rubyforge.org/template.html Source: http://rubyforge.org/cgi-bin/viewcvs.cgi/cerise/template.rb?rev=HEAD&cvsroot=cerise&content-type=text/vnd.viewcvs-markup This one should be easily customizable. It is only a few hundret lines of code. Amrita is kinda bloated compared to it, which is the reason the author of Cerise rolled his own. Sascha
On 22:56 Tue 15 Feb , Sascha Ebach wrote:> Jamis Buck wrote: > >Can anyone recommend another templating engine, similar to Amrita, > >that might not suffer under the limitations I described above? I''m > >still not convinced that there is real value in using a templating > >engine other than ERb, but I''m willing to try one for a little while > >to see what benefits might be gained. > > In an earlier message I recommended the template language which is based > on Amrita and integrated into Cerise (http://cerise.rubyforge.org/). > > Cerise Templates. > > http://cerise.rubyforge.org/template.html > > Source: > http://rubyforge.org/cgi-bin/viewcvs.cgi/cerise/template.rb?rev=HEAD&cvsroot=cerise&content-type=text/vnd.viewcvs-markup > > This one should be easily customizable. It is only a few hundret lines > of code. Amrita is kinda bloated compared to it, which is the reason the > author of Cerise rolled his own. > > SaschaThanks, Sascha. I''ll take a good look at the Cerise template stuff, too. - Jamis -- Jamis Buck jamis_buck-8Bzd4dk9+oo@public.gmane.org http://jamis.jamisbuck.org ------------------------------ "I am Victor of Borge. You will be assimil-nine-ed."
Hey Jamis,> Okay, for grins, I hacked (rudimentary) support for Amrita into > ActionView.very cool.> However, in doing so, I discovered a few things that I dislike about > Amrita, and I was wondering if anyone else (any experts here?)sorry, not an expert - and quite honestly, I haven''t done much new with amrita in quite some time (not that I really did anything that grand in the first place, but anyhow...)> 1. It uses the "id" attribute. I know you can force it to leave the > id''s in the output, instead of removing them, but even so it makes > it very hard to use the id''s effectively in DHTML. I would rather > see something like "oid", or "rwcid" (a la Tapestry).I believe you have two ways out. Both should be in Amrita::Template, there is an ''amrita_id'' attribute (to use your "oid" or whatever for amrita) and an ''escaped_id'' which can be used in a template and would fill the true ''id'' tag after amrita munging. they are in the rdocs. haven''t tested either. don''t know much about 2 or 3, but I''ll reread and have a look this weekend. as I said, it''s been a while.> 4. Amrita uses symbols as the hash keys. Rails uses strings.hmmm, that might be a problem. nothing springs to mind. And as for another templating engine, I really like how DHH put it. It''s really all about aesthetics. sorry I''m not much help. been pretty busy. thanks for taking a stab at it though. (btw, is there somewhere I can peek at what you''ve done?) Cameron
continuing the previous reply> > 4. Amrita uses symbols as the hash keys. Rails uses strings. > > hmmm, that might be a problem. nothing springs to mind.I don''t know about speed issues, but it appears there is a ''hash_key_is_string'' that defaults to false. It appears to do a key.to_s and is in the node_expand.rb file. (a context of the expand method of a template) the amrita_id and escaped_id work as I suggested (aka I tested them). still no thoughts on 2 or 3 (and I *really* do have to get some other stuff done, now. ;) Cameron
Jamis Buck wrote:> 2. It doesn''t, apparently, expand nested objects? Assuming an AR > Book, which belongs_to Author, and an array of books... > Where the author''s name should be, it is putting the result of > Author#to_s, i.e. "#<Author:@!#$@A@#$!@>". :(There''s a way to get this to work. We got it to work on one of our projects, but I can''t remember exactly how we did it right now. I think we may have done it using the technique described below. (I can find out when I am at work tommorrow if it would help.)> 3. Amrita::ExpandByMember. It seems to me that (especially with Rails) > this is just one more hoop to jump through. All AR''s need to have > this mixed in by default, and so do any other objects that you > happen to pass in.You can solve this problem by creating a proxy object which delegates to the real object and included Amrita::ExpandByMember. It is a clunky hack but it works. Proxy objects can allow you to do some pretty cool stuff.> 4. Amrita uses symbols as the hash keys. Rails uses strings. This > means that you have to explicitly convert the assigns arrays so > that the keys use symbols instead of strings, and doing this on > ever render is not going to be cheap (especially when there are > lots of values).A proxy object?> Can anyone recommend another templating engine, similar to Amrita, > that might not suffer under the limitations I described above? I''m > still not convinced that there is real value in using a templating > engine other than ERb, but I''m willing to try one for a little while > to see what benefits might be gained.I''ve been working on something and dreaming about seeing it eventually integrated into rails some day, but I''ve got to get a bit farther before it will be really useful. I''m basing my idea off of the templating systems of textpattern and movable type. A simple template might work like this: <ror:books top="5" order_by="newest"> <ror:author> <ror:name /> </ror:author> </ror:books> My thought is that you could integrate it tightly with rails by allowing instance variables to be automatically exposed to template designers in much the same way that it already works with ActionView. A few extra class methods could be used if necessary to add additional meta-data to be used in the template. If you are interested in seeing more I''ll post my current codebase (~50 lines of code) to my website. -- John
Thanks for the tips, Cameron. Much appreciated. - Jamis On 20:21 Tue 15 Feb , Cameron McBride wrote:> continuing the previous reply > > > > 4. Amrita uses symbols as the hash keys. Rails uses strings. > > > > hmmm, that might be a problem. nothing springs to mind. > > I don''t know about speed issues, but it appears there is a > ''hash_key_is_string'' that defaults to false. It appears to do a > key.to_s and is in the node_expand.rb file. (a context of the expand > method of a template) > > the amrita_id and escaped_id work as I suggested (aka I tested them). > > still no thoughts on 2 or 3 (and I *really* do have to get some other > stuff done, now. ;) > > Cameron > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jamis Buck jamis_buck-8Bzd4dk9+oo@public.gmane.org http://jamis.jamisbuck.org ------------------------------ "I am Victor of Borge. You will be assimil-nine-ed."
On 21:16 Tue 15 Feb , John W. Long wrote:> Jamis Buck wrote: > >2. It doesn''t, apparently, expand nested objects? Assuming an AR > > Book, which belongs_to Author, and an array of books... > > Where the author''s name should be, it is putting the result of > > Author#to_s, i.e. "#<Author:@!#$@A@#$!@>". :( > > There''s a way to get this to work. We got it to work on one of our > projects, but I can''t remember exactly how we did it right now. I think > we may have done it using the technique described below. (I can find out > when I am at work tommorrow if it would help.)If you can find a way to make it work, that would be great. At this point, though, I think I''m abandoning Amrita in favor of some of the other options that others have pointed out (like the Cerise templating engine). Not that I have tons of time to spend on this, but it''s fun to think about it.> > >3. Amrita::ExpandByMember. It seems to me that (especially with Rails) > > this is just one more hoop to jump through. All AR''s need to have > > this mixed in by default, and so do any other objects that you > > happen to pass in. > > You can solve this problem by creating a proxy object which delegates to > the real object and included Amrita::ExpandByMember. It is a clunky hack > but it works. Proxy objects can allow you to do some pretty cool stuff.Hmm. Yah, that could work. Wrapping all the data items in the proxy before adding them to the data hash. Might have to try that.> > >4. Amrita uses symbols as the hash keys. Rails uses strings. This > > means that you have to explicitly convert the assigns arrays so > > that the keys use symbols instead of strings, and doing this on > > ever render is not going to be cheap (especially when there are > > lots of values). > > A proxy object?Good point!> >Can anyone recommend another templating engine, similar to Amrita, > >that might not suffer under the limitations I described above? I''m > >still not convinced that there is real value in using a templating > >engine other than ERb, but I''m willing to try one for a little while > >to see what benefits might be gained. > > I''ve been working on something and dreaming about seeing it eventually > integrated into rails some day, but I''ve got to get a bit farther before > it will be really useful. I''m basing my idea off of the templating > systems of textpattern and movable type. A simple template might work > like this: > > <ror:books top="5" order_by="newest"> > <ror:author> > <ror:name /> > </ror:author> > </ror:books> > > My thought is that you could integrate it tightly with rails by allowing > instance variables to be automatically exposed to template designers > in much the same way that it already works with ActionView. A few extra > class methods could be used if necessary to add additional meta-data to > be used in the template. > > If you are interested in seeing more I''ll post my current codebase (~50 > lines of code) to my website.Interesting idea. I''d like to take a peek at it if I have a minute, so go ahead and post it if you have a chance. Thanks for the ideas! - Jamis -- Jamis Buck jamis_buck-8Bzd4dk9+oo@public.gmane.org http://jamis.jamisbuck.org ------------------------------ "I am Victor of Borge. You will be assimil-nine-ed."
> If you can find a way to make it work, that would be great. At this > point, though, I think I''m abandoning Amrita in favor of some of the > other options that others have pointed out (like the Cerise templating > engine).well, that is no fun. at least let some of us have a look at what you did with Amrita. ;)> > If you are interested in seeing more I''ll post my current codebase (~50 > > lines of code) to my website. > > Interesting idea. I''d like to take a peek at it if I have a minute, so > go ahead and post it if you have a chance.yes, yes. I''m interested as well. Cameron
On 18:05 Wed 16 Feb , Cameron McBride wrote:> > If you can find a way to make it work, that would be great. At this > > point, though, I think I''m abandoning Amrita in favor of some of the > > other options that others have pointed out (like the Cerise templating > > engine). > > well, that is no fun. at least let some of us have a look at what you > did with Amrita. ;)As you wish. :) http://ruby.jamisbuck.org/amrita-view.zip I''m releasing it into the public domain, so do with it as you wish. It was mostly just an spare-minute exercise to see what could be done. The only part of it that I think may have redeeming value is stuff I added to ActionView::Base to allow different view handlers to be registered and used. It would make it easier, at least, to play with different template engines. - Jamis -- Jamis Buck jamis_buck-8Bzd4dk9+oo@public.gmane.org http://jamis.jamisbuck.org ------------------------------ "I am Victor of Borge. You will be assimil-nine-ed."
> 2. It doesn''t, apparently, expand nested objects? Assuming an AR> Book, which belongs_to Author, and an array of books... > Where the author''s name should be, it is putting the result of > Author#to_s, i.e. "#<Author:@!#$@A@#$!@>". :( Looking at our code I didn''t see that we were doing anything special to get it to expand nested objects. Are you sure Amrita::ExpandByMember was included in Author? > Hmm. Yah, that could work. Wrapping all the data items in the proxy > before adding them to the data hash. Might have to try that. I''ve put what we we were using up on my Web site here: http://johnwlong.com/downloads/wrapper/ Be warned, it was made by a couple of Java programmers. Here''s an example of how we used it: map = { :registration => Wrapper.new(@registration, :registrant => adapt_registrant(registrant), :event => Wrapper.new(@registration.event, :dates => adapt_dates(@registration.event), :ci_exists =>@registration.event.ci_event? ) } map[:registration].conditional(:can_process) { @registration.total_amount == 0 } The basic concept is that you have a Wrapper proxy object which delegates method calls to his object. But, as shown above, you can also define extensions on that object which are returned instead of calling the method. This is especially useful when you want to add presentation behavior to the template without poluting your model. >> I''ve been working on something and dreaming about seeing it >> eventually integrated into rails some day, but I''ve got to get a bit >> farther before it will be really useful. I''m basing my idea off of >> the templating systems of textpattern and movable type. A simple >> template might work like this: >> >> <ror:books top="5" order_by="newest"> >> <ror:author> >> <ror:name /> >> </ror:author> >> </ror:books> >> >> My thought is that you could integrate it tightly with rails by >> allowing instance variables to be automatically exposed to template >> designers in much the same way that it already works with ActionView. >> A few extra class methods could be used if necessary to add >> additional meta-data to be used in the template. >> >> If you are interested in seeing more I''ll post my current codebase >> (~50 lines of code) to my website. > > Interesting idea. I''d like to take a peek at it if I have a minute, so > go ahead and post it if you have a chance. There ya go: http://johnwlong.com/downloads/template/ -- John
Hello, I''m the author of Amrita. Thank you for integrating Amrita into Rails.> Can anyone recommend another templating engine, similar to Amrita, > that might not suffer under the limitations I described above?I have rewritten Amrita from scratch. And I''m releasing it as Amrita2. Though it is my personal project now, I will setup the project site public until next week and announce it at ruby-talk. I''d like to make Amrita2 fit Rails. Rails will be one of the main target of Amrita2. I''m very delighted to hear about requests of Rails users using templates.> However, in doing so, I discovered a few things that I dislike about > Amrita, and I was wondering if anyone else (any experts here?) could > indicate whether there are work arounds, or whether this is just the > way it is with Amrita:Amrita2 has almost cleard these points now.> 1. It uses the "id" attribute. I know you can force it to leave the > id''s in the output, instead of removing them, but even so it makes > it very hard to use the id''s effectively in DHTML. I would rather > see something like "oid", or "rwcid" (a la Tapestry).The attribute for pointing dynamic element can be changed with Amrita. I will implement the same interface to Amrita2, too.> 2. It doesn''t, apparently, expand nested objects? Assuming an AR > Book, which belongs_to Author, and an array of books: > > <tr id="books"> > <td id="author"> > <span id="name"></span> > </td> > </tr> > > Where the author''s name should be, it is putting the result of > Author#to_s, i.e. "#<Author:@!#$@A@#$!@>". :( > > 3. Amrita::ExpandByMember. It seems to me that (especially with Rails) > this is just one more hoop to jump through. All AR''s need to have > this mixed in by default, and so do any other objects that you > happen to pass in. Seems like this ought to be a feature of every > object, by default.Amrita2 can expand data by member without Amrita::ExpandByMember or something like that. You can pass almost any Ruby objects to Amrita2. See the example later for details.> 4. Amrita uses symbols as the hash keys. Rails uses strings. This > means that you have to explicitly convert the assigns arrays so > that the keys use symbols instead of strings, and doing this on > ever render is not going to be cheap (especially when there are > lots of values).Amrita2 acepts hashes with string keys and symbol keys equally. You can get the latest pre-alpha version here. http://amrita.s14.xrea.com/files/amrita2_050217.tar.gz This is the only document for Amrita2 now. http://amrita.s14.xrea.com/files/README_FOR_1_0_USERS.html Here is a sample of Amrita2. (sample/hello/structs.rb) --------------------------------------------------------------------- require "amrita2/template" include Amrita2 Lang = Struct.new(:name, :author, :website) WebSite = Struct.new(:name, :url) data = { ''table1''=>[ Lang.new("Ruby", "matz", WebSite.new(''Ruby Home Page'', ''http://www.ruby-lang.org/'')), Lang.new("Perl", "Larry Wall", WebSite.new(''The Source for Perl'', ''http://perl.com/'')), Lang.new("Python","Guido van Rossum", WebSite.new(''Python Programing Language'', ''http://www.python.org/'')) ] } tmpl = TemplateText.new <<END <table border=''1''> <tr><th>name</th><th>author</th></tr> <tr id=''table1''> <td id=''name''></td> <td id=''author''></td> <td id=''website''><span id=''name'' /> <br /> <span id=''url'' /></td> </tr> </table> END tmpl.expand(STDOUT, data) --------------------------------------------------------------------- output is <table border=''1''> <tr><th>name</th><th>author</th></tr> <tr><td>Ruby</td><td>matz</td><td><span>Ruby Home Page</span><br></br><span>http://www.ruby-lang.org/</span></td></tr> <tr><td>Perl</td><td>Larry..... </table> --------------------------------------------------------------------- class WebSite # presentation logic for putting data into attribute def site(m) # m is a part of template modules which contains # methods for dynamic element m.site(self.name, :href=>self.url) end end tmpl = TemplateText.new <<END <table border=''1''> <tr><th>name</th><th>author</th><th>website</th></tr> <tr id=''table1''> <td id=''name''></td> <td id=''author''></td> <td id=''website''><a id=''site''/></td> </tr> </table> END tmpl.expand(STDOUT, data) --------------------------------------------------------------------- <table border=''1''> <tr><th>name</th><th>author</th><th>website</th></tr> <tr><td>Ruby</td><td>matz</td><td><a href=''http://www.ruby-lang.org/''>Ruby Home Page</a></td></tr> <tr><td>Perl</td><td>Larry..... </table> --------------------------------------------------------------------- --- Taku Nakajima
On 21:56 Thu 17 Feb , Taku Nakajima wrote:> > Hello, I''m the author of Amrita. Thank you for integrating Amrita into > Rails.Thank-you for your response, Taku. The new Amrita looks very promising--I look forward to playing with it! - Jamis> > Can anyone recommend another templating engine, similar to Amrita, > > that might not suffer under the limitations I described above? > > I have rewritten Amrita from scratch. And I''m releasing it as > Amrita2. > > Though it is my personal project now, I will setup the project site > public until next week and announce it at ruby-talk. > > I''d like to make Amrita2 fit Rails. Rails will be one of the main > target of Amrita2. I''m very delighted to hear about requests of Rails > users using templates. > > > However, in doing so, I discovered a few things that I dislike about > > Amrita, and I was wondering if anyone else (any experts here?) could > > indicate whether there are work arounds, or whether this is just the > > way it is with Amrita: > > Amrita2 has almost cleard these points now. > > > 1. It uses the "id" attribute. I know you can force it to leave the > > id''s in the output, instead of removing them, but even so it makes > > it very hard to use the id''s effectively in DHTML. I would rather > > see something like "oid", or "rwcid" (a la Tapestry). > > The attribute for pointing dynamic element can be changed with > Amrita. I will implement the same interface to Amrita2, too. > > > 2. It doesn''t, apparently, expand nested objects? Assuming an AR > > Book, which belongs_to Author, and an array of books: > > > > <tr id="books"> > > <td id="author"> > > <span id="name"></span> > > </td> > > </tr> > > > > Where the author''s name should be, it is putting the result of > > Author#to_s, i.e. "#<Author:@!#$@A@#$!@>". :( > > > > 3. Amrita::ExpandByMember. It seems to me that (especially with Rails) > > this is just one more hoop to jump through. All AR''s need to have > > this mixed in by default, and so do any other objects that you > > happen to pass in. Seems like this ought to be a feature of every > > object, by default. > > Amrita2 can expand data by member without Amrita::ExpandByMember or > something like that. You can pass almost any Ruby objects to Amrita2. > See the example later for details. > > > 4. Amrita uses symbols as the hash keys. Rails uses strings. This > > means that you have to explicitly convert the assigns arrays so > > that the keys use symbols instead of strings, and doing this on > > ever render is not going to be cheap (especially when there are > > lots of values). > > Amrita2 acepts hashes with string keys and symbol keys equally. > > You can get the latest pre-alpha version here. > > http://amrita.s14.xrea.com/files/amrita2_050217.tar.gz > > This is the only document for Amrita2 now. > > http://amrita.s14.xrea.com/files/README_FOR_1_0_USERS.html > > > Here is a sample of Amrita2. (sample/hello/structs.rb) > --------------------------------------------------------------------- > require "amrita2/template" > include Amrita2 > > Lang = Struct.new(:name, :author, :website) > WebSite = Struct.new(:name, :url) > data = { > ''table1''=>[ > Lang.new("Ruby", "matz", WebSite.new(''Ruby Home Page'', ''http://www.ruby-lang.org/'')), > Lang.new("Perl", "Larry Wall", WebSite.new(''The Source for Perl'', ''http://perl.com/'')), > Lang.new("Python","Guido van Rossum", WebSite.new(''Python Programing Language'', ''http://www.python.org/'')) > ] > } > > tmpl = TemplateText.new <<END > <table border=''1''> > <tr><th>name</th><th>author</th></tr> > <tr id=''table1''> > <td id=''name''></td> > <td id=''author''></td> > <td id=''website''><span id=''name'' /> <br /> <span id=''url'' /></td> > </tr> > </table> > END > > tmpl.expand(STDOUT, data) > --------------------------------------------------------------------- > output is > > <table border=''1''> > <tr><th>name</th><th>author</th></tr> > <tr><td>Ruby</td><td>matz</td><td><span>Ruby Home Page</span><br></br><span>http://www.ruby-lang.org/</span></td></tr> > <tr><td>Perl</td><td>Larry..... > </table> > --------------------------------------------------------------------- > > class WebSite > # presentation logic for putting data into attribute > def site(m) > # m is a part of template modules which contains > # methods for dynamic element > m.site(self.name, :href=>self.url) > end > end > > tmpl = TemplateText.new <<END > <table border=''1''> > <tr><th>name</th><th>author</th><th>website</th></tr> > <tr id=''table1''> > <td id=''name''></td> > <td id=''author''></td> > <td id=''website''><a id=''site''/></td> > </tr> > </table> > END > tmpl.expand(STDOUT, data) > > --------------------------------------------------------------------- > <table border=''1''> > <tr><th>name</th><th>author</th><th>website</th></tr> > <tr><td>Ruby</td><td>matz</td><td><a href=''http://www.ruby-lang.org/''>Ruby Home Page</a></td></tr> > <tr><td>Perl</td><td>Larry..... > </table> > --------------------------------------------------------------------- > > --- > Taku Nakajima > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jamis Buck jamis_buck-8Bzd4dk9+oo@public.gmane.org http://jamis.jamisbuck.org ------------------------------ "I am Victor of Borge. You will be assimil-nine-ed."
On Thu, 17 Feb 2005, Jamis Buck wrote:> On 21:56 Thu 17 Feb , Taku Nakajima wrote: >> >> Hello, I''m the author of Amrita. Thank you for integrating Amrita into >> Rails. > > Thank-you for your response, Taku. The new Amrita looks very > promising--I look forward to playing with it!yes - a big thank you taku! i''ve used amrita extensively in the past and always felt it was one of ruby''s most under-rated libraries. rails is great now - but good templating would make it that much better : code does not belong in html. i hope you are able to go somewhere here jamis! cheers. -a -- ==============================================================================| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================
> I have rewritten Amrita from scratch. And I''m releasing it as > Amrita2.(snip)> Amrita2 can expand data by member without Amrita::ExpandByMember or > something like that. You can pass almost any Ruby objects to Amrita2. > See the example later for details.(snip)> This is the only document for Amrita2 now. > > http://amrita.s14.xrea.com/files/README_FOR_1_0_USERS.html(I like that block syntax, too) This looks fantastic. Thank you, Taku! Very exciting, indeed. Cameron
Hello Nakajima-san ! According to Taku Nakajima:> I have rewritten Amrita from scratch. And I''m releasing it as > Amrita2.Good news! So I guess it is not based on 1.8.2 either? Th eproject I mentionned in this thread was using 1.8.2 because 1.0.2 lacked many features.> Though it is my personal project now, I will setup the project site > public until next week and announce it at ruby-talk.Looking forward to that! -- Ollivier ROBERT -=- FreeBSD: The Power to Serve! -=- roberto-0kjVc+YyuDZX+h8frlqCcVAUjnlXr6A1@public.gmane.org Darwin snuadh.freenix.org Kernel Version 7.8.0: Wed Dec 22 14:26:17 PST 2004
> I''d like to make Amrita2 fit Rails. Rails will be one of the main > target of Amrita2. I''m very delighted to hear about requests of Rails > users using templates.This sounds great, Taku. While I personally don''t find it a good fit for my needs, Amrita certainly has stolen the hearts of many developers. Under your involvement, I''d be happy to see Rails support Amrita as an viable alternative to the primaries of ERb and Builder. Keep it up! -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://www.loudthinking.com/ -- Broadcasting Brain
> I have rewritten Amrita from scratch. And I''m releasing it as > Amrita2.Unless I''m misunderstanding something, according to the inlcuded do_bench.rb your rewrite has some nice speed increases over amrita (with the exception of the use_hint option). Great work and thanks! Cameron
>> I''d like to make Amrita2 fit Rails. Rails will be one of the main >> target of Amrita2. I''m very delighted to hear about requests of Rails >> users using templates. > > This sounds great, Taku. While I personally don''t find it a good fit > for my needs, Amrita certainly has stolen the hearts of many > developers. Under your involvement, I''d be happy to see Rails support > Amrita as an viable alternative to the primaries of ERb and Builder. > Keep it up!By virtue of Jamis Buck, you can now do ActionView::Base.register_template_handler(extension, handler) -- which should make it easy to integrate any kind of template engine with ActionView. I''d especially like to see Amrita2 and PageTemplate (sounds fast). Any integration should work such that nothing in Rails need to change (as Rails won''t bundle these engines). So figure out a way of making it automatically hook in with this call by just having the user add one line to his environment file. -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://www.loudthinking.com/ -- Broadcasting Brain
Thanks for many replies about Amrita. At Fri, 18 Feb 2005 06:24:34 -0500, Cameron McBride wrote:> > > I have rewritten Amrita from scratch. And I''m releasing it as > > Amrita2. > > Unless I''m misunderstanding something, according to the inlcuded > do_bench.rb your rewrite has some nice speed increases over amrita > (with the exception of the use_hint option). Great work and thanks!Yes, I have not done any optimization to Amrita2, it runs as fast as Amrita''s top speed now. Here is the latest result in my machine. title system user total one transaction(MS) interpreter 4.96 1.43 6.39 63.90 amrita2 0.72 0.30 1.02 10.20 amrita2(pasvpo) 1.17 0.15 1.32 13.20 preformat 3.22 0.57 3.79 37.90 compiler 1.43 0.15 1.58 15.80 use hint 0.80 0.12 0.92 9.20 eruby 0.02 0.01 0.03 0.30 plain ruby 0.03 0.01 0.04 0.40 ''amrita2'' is using amrita2 with new API, ''amrita2(pasvpo)'' is with old amrita-like API. They both runs faster than ''compiler'' which runs amrita with use_compiler option. ''use_hint'' means using amrita with optimization by ''set_hint_by_sample_data'' method. Amrita2 is a HTML to Ruby Compiler. So I think there are many things to do for optimization. And Amrita2 has a good interface called ''template spec'' for specifing optimize option for compiling. I can''t say that plain Amrita2 is very fast but I think you can make Amrita2 fast enough if you can find hot spots and set an option for it. I registerd Amrita2 at rubyforge. http://rubyforge.org/projects/amrita2/ There are nothing but CVS repository now. You can test it from CVS. At Thu, 17 Feb 2005 18:07:21 +0100, Ollivier Robert wrote:> > Hello Nakajima-san ! > > According to Taku Nakajima: > > I have rewritten Amrita from scratch. And I''m releasing it as > > Amrita2. > > Good news! So I guess it is not based on 1.8.2 either? Th eproject I > mentionned in this thread was using 1.8.2 because 1.0.2 lacked many > features.1.8.2 has become too complicated to maintain . So I threw it up before release. But I''ve got many things from it. The new Amrita2 has similar architecture to 1.8.2 . But it is simpler and more flexible. --- Taku Nakajima