RJS templates outputting bloated code?


#1

I’m an RJS newbie. I just did the tutorial at
http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates, and
then used wget to look at the output the RJS template generates. This is
what I got:

try {
new Insertion.Bottom(“list”, “

  • Fox
  • ”);
    new Effect.Highlight(“list”,{duration:1});
    Element.update(“header”, “RJS Template Test Complete”);
    } catch (e) { alert(‘RJS error:\n\n’ + e.toString()); alert(‘new
    Insertion.Bottom(“list”, “
  • Fox
  • ”);\nnew
    Effect.Highlight(“list”,{duration:1})
    ;\nElement.update(“header”, “RJS Template Test Complete”);’); throw
    e }

    It looks to me like the exception handling logic sent in the response
    causes too much bloat. I think it’s better to send only the “meat”:

    new Insertion.Bottom(“list”, “

  • Fox
  • ”);
    new Effect.Highlight(“list”,{duration:1});
    Element.update(“header”, “RJS Template Test Complete”);

    Thoughts?


    #2

    On 3/31/06, Yariv S. removed_email_address@domain.invalid wrote:

    Insertion.Bottom(“list”, “

  • Fox
  • ”);\nnew
    Element.update(“header”, “RJS Template Test Complete”);

    Thoughts?

    Hi. This behavior only exists (by default) in development. Look at
    your config/environments/development.rb file and you should see a
    setting for RJS debug. This will help you during development but it
    shouldn’t show up on production.


    Chad F.
    http://chadfowler.com
    http://pragmaticprogrammer.com/titles/fr_rr/ (Rails Recipes - In Beta!)
    http://pragmaticprogrammer.com/titles/mjwti/ (My Job Went to India,
    and All I Got Was This Lousy Book)
    http://rubycentral.org
    http://rubygarden.org
    http://rubygems.rubyforge.org (over one million gems served!)


    #3

    On 3/31/06, Yariv S. removed_email_address@domain.invalid wrote:

    Hi. This behavior only exists (by default) in development. Look at
    your config/environments/development.rb file and you should see a
    setting for RJS debug. This will help you during development but it
    shouldn’t show up on production.

    Excellent! I knew you guys have probably thought of this :slight_smile: Keep up the
    great work!

    Well, I can’t personally claim to have thought of anything other than
    asking Sam S. recently about the best ways to debug RJS, which
    is when he told me about this feature :slight_smile:


    Chad F.
    http://chadfowler.com
    http://pragmaticprogrammer.com/titles/fr_rr/ (Rails Recipes - In Beta!)
    http://pragmaticprogrammer.com/titles/mjwti/ (My Job Went to India,
    and All I Got Was This Lousy Book)
    http://rubycentral.org
    http://rubygarden.org
    http://rubygems.rubyforge.org (over one million gems served!)


    #4

    Hi. This behavior only exists (by default) in development. Look at
    your config/environments/development.rb file and you should see a
    setting for RJS debug. This will help you during development but it
    shouldn’t show up on production.

    Excellent! I knew you guys have probably thought of this :slight_smile: Keep up the
    great work!

    Yariv