Meta helper help

I’d like to write a helper thats used like this:

<%= template_info %>

which replaces code like this:

<% if RAILS_ENV == “development” %>

Template: <%= __FILE__ %>
<% end %>

but when i write my helper it outputs the name of the helper file,
not the template! Or just a string when I try to enclose it in <% %>
How do i write a helper to output erb code thats then rendered as
part of the calling template? is that possible?

def template_info
if RAILS_ENV == “development”
#FILE
#"<%= FILE %>"
#content_tag(“div”, “<%= FILE %>”, :class =>
“template_info” )
end
end

hi, i found the answer – method “caller”

so here’s a neat little helper you also might like
http://pastie.caboo.se/67118

Now the question is, could i get render to insert this automatically
at the end of each template (perhaps embeded in ) and toggle
it with an environment config variable???

helper

def template_info( update = nil, *info )
if RAILS_ENV == “development”
info.insert(0, “Last update: " + update.to_s(:short)) if update
f = caller[0]
f = f[0,f.index(‘:’)]
f = f.split(”/“).last(2).join(”/“)
info.insert(0, “Template: #{f}”)
content_tag(“div”, info.join(”
"), :class =>
“template_info” )
end
end

template examples

<%= template_info %>
<%= template_info @page.updated_at %>
<%= template_info @page.updated_at, “by #{@page.author.name}” %>

example html result

Template: pages/show.html.erb
Last update: 31 May 16:31