Hi,

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...

And this is what I would like to accomplish, and by the way, I
consider this a very basic function of a web framework:

- I don't use any Javascript generated by Rails. I don't like
Prototype, and I sure don't like inline Javascript
- I believe in separation of HTML and JS.
- I load any JS files AT THE END of the HTML (bottom of application
layout file)
- I load jquery (or YUI, that's the two JS-libs I like - jquery for
smaller jobs, YUI for real applications rather than just some add-on
code for a page), and then I add some page specific code. I have NO
code inline, and I sure won't let Rails insert any inline code, so as
I said, I don't use rails JS helpers or .rjs files. Ever. JS code
remains 100% separate.

- For page specific code I would like to use a file with the exact
same name as the .html.erb view file, in the same directory. I don't
want to have the JS code inline in the view file. That's bad not just
because I want it all logically separated, but also because editors
have a very hard time handling mixed HTML/CSS/JS code. Especially if
it's more than a few lines of code that means trouble. It is much
better to have JS code in a separate file.

- I would like my application layout template to look for .js files
for the current view template file, and if present, insert them into
the page (at the very bottom into a script section). The issue I have
and ask about right here would be the same if I inserted a link to
that JS file instead, but in order to avoid an additional HTTP
download I prefer to insert the code. It is guarded by an onDOMReady
event fired by the jquery or YUI library, which is loaded before that
page specific code.

What still prevents me from doing this is that I don't know how to
generically find out the name of the currently used view template
inside the ruby code of the application template layout file, and I
sure don't want to have to set a variable in the controller for this
purpose - I'm sure Rails has that info _somewhere_. Please help me
locate it :-)

Thanks!

Michael
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to