Hi, I would like to use some ERB in my javascript files. How can I do this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Check out Dan Webb''s MinusMOR plugin... http://www.danwebb.net/2006/11/24/minusmor-released be sure to read the background as well... http://www.danwebb.net/2006/11/17/rjs-minus-r Peter On Sep 14, 8:45 pm, eggie5 <egg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I would like to use some ERB in my javascript files. > > How can I do this?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
eggie5 wrote:> I would like to use some ERB in my javascript files. > > How can I do this?Someone might know a better way than writing a partial rhtml file, putting a <script> tag in it, and filling this with JavaScript and <%%> tags... -- Phlip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
msnapper wrote:> Check out Dan Webb''s MinusMOR plugin... > > http://www.danwebb.net/2006/11/24/minusmor-releasedKewt! Can I use it inside a :update do |page| block ? -- Phlip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, Sep 14, 2007 at 09:17:49PM -0700, Phlip wrote:> eggie5 wrote: > > I would like to use some ERB in my javascript files. > > > > How can I do this? > > Someone might know a better way than writing a partial rhtml file, > putting a <script> tag in it, and filling this with JavaScript and <%%> > tags...Well, yes, there is a better way. It mainly lets you avoid the script tag and refer to the JS with a normal javascript_include_tag call (which means easy caching). Here''s a toy example: ### script_controller class ScriptController < ApplicationController def foo_js @necessary_data = Foo.get_that_necessary_data render :layout => false, :type => ''text/javascript'' end end ### foo_js.rhtml <%# eruby_subtype=js -%> MyCacheOfNecessaryData = <%= @necessary_data.to_json %>; (Note that the eruby_subtype line is a hint to vim 7.1 and later to get syntax of the file right.) Naturally, the majority of your JS will be static code and should be served as such, but when you have some data that needs to be available to the client-side JS, this is a useful idiom.> Phlip--Greg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---