(FYI - I consider this a vary basic setup for anyone using _proper_ Javascript, i.e. not inline code, something Rails generates unfortunately)
Okay.... so in Rails 2.3.1 (RC2) I cannot do it in the layout file alone any more. I have to remember the template name in (each) view in an instance variable, and then I can use that in the layout file. Details: somewhere in the view for which there exists an extra JS file: <%- @view_na...@_render_stack[0].template_path -%> Since this is again an "underscore variable" and undocumented onne cannot rely on it existing in the next Rails release, but I'm sure it will be fairly easy to find something similar then. In the layout file (the JS files have to be named "_viewname.js"): <%- unless @view_name.blank? -%> <%= render @view_name.gsub(/.html.erb\s*$/,'')+'.js' %> <%- end -%> <[email protected]> wrote: > I would like to access the filename of the (main) template used for a > request, and I would like to do so in the (main application) layout > template. I know about @template, but @template.template.filename > yields the filename of the application template file, not of the view > template file. On the other hand, the filename is in @template > somewhere - I can see it when I look at @template.inspect. I'm just > too stupid to find out where exactly... >... --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

