Could you explain the problem in a little more depth? Maybe there's another way to achieve what you're trying to do, aside from finding the template name?
Gav On 26 Feb, 16:18, Rob Lacey <[email protected]> wrote: > Thanks for the help Gavin, it wasn't quite what I was looking for. Its a > bit of a weird one. Given a particular layout I want to know the name of > the template that is used in the > > <%= yield %> > > Which is a bit weird, I know. I would imagine that the results of the > yield are just a big string, by which time its a bit late to work out > what the name of the template I just rendered was. > > Hmmzzz. Thanks all the same :) > > RobLhttp://www.robl.me > > Gavin wrote: > > Hey Rob - > > I think I understand the question > > > Is this what you're looking for: > > > template will return the full name of the current template > > > if you stick it in your layout it'll just render the name of the > > layout. > > > If you stick it in each template (a little more work) then it'll > > return the name of the template. > > > Id stick this in an application_helper like so: > > > def this_temp > > template.to_s.split(".")[0] > > end > > > This hacks of the filetype extention (html.erb) leaving just the name > > > Calling this in the view will give you > > <%= this_temp %> => mains/new > > > Hope that helps? > > > On Feb 26, 12:52 pm, Rob Lacey <[email protected]> wrote: > > >> Hey guys, > > >> I'm trying to extract the name of the template I am currently to be > >> yielding from my layout, but with no success. Does anyone know how to do > >> that? > > >> Suppose I am calling the MainController#create action. On failure to > >> create my erm...Main object it re-renders the 'new' template. I'd like > >> to know in the layout which template I am going to render so that I can > >> access a help system which can dynamically include help information > >> depending on which template I am rendering at the time. Then no matter > >> what controller or what action I am calling at the time, as long as I > >> have the template name I can display the same information. > > >> Any ideas? > > >> RobLhttp://www.robl.me --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

