I''m writing some new code and I''m considering using the Template functions of prototype. I''ve never used Template before. Is this function fast or would it be faster to return HTML from the server? In particular for a table with 250 items. Thanks for the advice! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
How will you be building the table? I assume you''re weighing the difference between returning HTML from the server, and returning something like JSON from the server and building the table in JS? I''d say building a 250 row table in JS with a Template will be plenty fast (will be noticeably faster than a DOM builder), and you can probably take advantage of some code reuse if you want to add/remove/reorder table rows dynamically. If the table is going to remain relatively static, probably no need to bother doing it on the client side. -Fred On Tue, Jun 24, 2008 at 9:21 AM, Namotco <namotco-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m writing some new code and I''m considering using the Template > functions of prototype. I''ve never used Template before. Is this > function fast or would it be faster to return HTML from the server? > In particular for a table with 250 items.-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I am planning to add/remove/change rows dynamically with a JSON object. I will need to create a new template if I want to change how many rows there will be though, correct? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Use one template for the rows inside a loop, and then wrap it in a <table>. -Fred On Tue, Jun 24, 2008 at 2:08 PM, Namotco <namotco-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I am planning to add/remove/change rows dynamically with a JSON > object. I will need to create a new template if I want to change how > many rows there will be though, correct?-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Namotco wrote:> I''m writing some new code and I''m considering using the Template > functions of prototype. I''ve never used Template before. Is this > function fast or would it be faster to return HTML from the server? > In particular for a table with 250 items. > > Thanks for the advice!A few years ago I created a compile template class that compiles a template so that it can be evaluated very quickly. It is great for these situations where you are creating html from json. Check out the source with a table example at the end. http://pastie.org/221410 You may also notice that it supports complex Smarty-like constructs such as {if} and {foreach} and allows you to write more handlers for custom tags. - Ken Snyder --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ken, pre-instantiating prototype''s Template is actually relatively fast (vs. just using #interpolate on a string) Have you, by any chance, done any benchmarking? - kangax On Jun 24, 5:02 pm, Ken Snyder <kendsny...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Namotco wrote: > > I''m writing some new code and I''m considering using the Template > > functions of prototype. I''ve never used Template before. Is this > > function fast or would it be faster to return HTML from the server? > > In particular for a table with 250 items. > > > Thanks for the advice! > > A few years ago I created a compile template class that compiles a > template so that it can be evaluated very quickly. It is great for > these situations where you are creating html from json. > > Check out the source with a table example at the end. > > http://pastie.org/221410 > > You may also notice that it supports complex Smarty-like constructs such > as {if} and {foreach} and allows you to write more handlers for custom tags. > > - Ken Snyder--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
kangax wrote:> Ken, > pre-instantiating prototype''s Template is actually relatively fast > (vs. just using #interpolate on a string) > Have you, by any chance, done any benchmarking? > > - kangax >I''ve done no benchmarking since the main functionality I wanted was if and foreach. But I''d be surprised if the eval() approach wasn''t significantly faster than the gsub() approach. I''ve got a new version in the works so I''ll have to do some benchmarking. - Ken --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---