mixtli
2009-Apr-03 13:06 UTC
Anyone know a way to create html comments with the names of the views?
I work with a lot of designers. The question I get all the time is: Where is the template that displays xyz? I was thinking it would be nice if rails would print the name of each template it loads as an html comment like so: <!-- LAYOUT: layouts/application.html.erb --> <html><head>etc..</head> <body> <!-- TEMPLATE: blog/index.html.erb --> <!-- TEMPLATE: blog/_side_bar.html.erb --> </body> </html> Not having to answer these questions all day would really make my day. I poked around the rails code for a couple hours and don''t see an obvious way. Does anyone have an idea on how to do this? Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Apr-03 14:07 UTC
Re: Anyone know a way to create html comments with the names of the views?
On Apr 3, 2:06 pm, mixtli <ronmcclai...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I work with a lot of designers. The question I get all the time is: > Where is the template that displays xyz? I was thinking it would be > nice if rails would print the name of each template it loads as an > html comment like so: >Seems like you can do this by overriding render_template in template.rb. Seems like a fairly handy idea actually, when I have worked with designers that''s definitely a question that has come up often! Fred> <!-- LAYOUT: layouts/application.html.erb --> > <html><head>etc..</head> > <body> > <!-- TEMPLATE: blog/index.html.erb --> > <!-- TEMPLATE: blog/_side_bar.html.erb --> > </body> > </html> > > Not having to answer these questions all day would really make my day. > I poked around the rails code for a couple hours and don''t see an > obvious way. Does anyone have an idea on how to do this? > > Thanks!--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
emanuele tozzato
2009-Apr-03 14:14 UTC
Re: Anyone know a way to create html comments with the names of the views?
NICE! It will be my next plugin! If nil? of course! ;) iPhonized! On Apr 3, 2009, at 6:06 AM, mixtli <ronmcclain75-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I work with a lot of designers. The question I get all the time is: > Where is the template that displays xyz? I was thinking it would be > nice if rails would print the name of each template it loads as an > html comment like so: > > <!-- LAYOUT: layouts/application.html.erb --> > <html><head>etc..</head> > <body> > <!-- TEMPLATE: blog/index.html.erb --> > <!-- TEMPLATE: blog/_side_bar.html.erb --> > </body> > </html> > > Not having to answer these questions all day would really make my day. > I poked around the rails code for a couple hours and don''t see an > obvious way. Does anyone have an idea on how to do this? > > Thanks! > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
mixtli
2009-Apr-03 14:50 UTC
Re: Anyone know a way to create html comments with the names of the views?
For now, I just slapped this in a file in lib and include it in environment.rb: module ActionView class Template def render_template(view, local_assigns = {}) "<!-- TEMPLATE: #{self.template_path} -->\n" + render(view, local_assigns) rescue Exception => e raise e unless filename if TemplateError === e e.sub_template_of(self) raise e else raise TemplateError.new(self, view.assigns, e) end end end end Works in Rails 2.3 anyway. I''m sure there is a cleaner way, and it should probably be made into an environment specific config option. But I''m in a hurry right now. Thanks for the pointer. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
mixtli
2009-Apr-03 15:11 UTC
Re: Anyone know a way to create html comments with the names of the views?
Use "<!-- TEMPLATE: #{self.load_path}/#{self.template_path} -->\n" instead to get the full path from RAILS_ROOT. Useful if you''re pulling in views from plugins/engines. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Apr-03 17:50 UTC
Re: Anyone know a way to create html comments with the names of the views?
On 3 Apr 2009, at 15:50, mixtli wrote:> > > For now, I just slapped this in a file in lib and include it in > environment.rb: >For what it''s worth i''ve pluginised this: http://github.com/fcheung/tattler/tree/master Fred> module ActionView > class Template > def render_template(view, local_assigns = {}) > "<!-- TEMPLATE: #{self.template_path} -->\n" + render(view, > local_assigns) > rescue Exception => e > raise e unless filename > if TemplateError === e > e.sub_template_of(self) > raise e > else > raise TemplateError.new(self, view.assigns, e) > end > end > end > end > > > Works in Rails 2.3 anyway. I''m sure there is a cleaner way, and it > should probably be made into an environment specific config option. > But I''m in a hurry right now. > > Thanks for the pointer. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2009-Apr-03 17:53 UTC
Re: Anyone know a way to create html comments with the names of the views?
Coming in late, but there''s also this.. http://github.com/gwynm/noisy_partials/tree/master>> For now, I just slapped this in a file in lib and include it in >> environment.rb: >> > For what it''s worth i''ve pluginised this: http://github.com/fcheung/tattler/tree/master > > Fred >> module ActionView >> class Template >> def render_template(view, local_assigns = {}) >> "<!-- TEMPLATE: #{self.template_path} -->\n" + render(view, >> local_assigns) >> rescue Exception => e >> raise e unless filename >> if TemplateError === e >> e.sub_template_of(self) >> raise e >> else >> raise TemplateError.new(self, view.assigns, e) >> end >> end >> end >> end >> >> >> Works in Rails 2.3 anyway. I''m sure there is a cleaner way, and it >> should probably be made into an environment specific config option. >> But I''m in a hurry right now. >> >> Thanks for the pointer. >> >>> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Julian Leviston
2009-Apr-03 18:28 UTC
Re: Anyone know a way to create html comments with the names of the views?
My designer works it out from the URL and routes file Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 04/04/2009, at 12:06 AM, mixtli <ronmcclain75-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I work with a lot of designers. The question I get all the time is: > Where is the template that displays xyz? I was thinking it would be > nice if rails would print the name of each template it loads as an > html comment like so: > > <!-- LAYOUT: layouts/application.html.erb --> > <html><head>etc..</head> > <body> > <!-- TEMPLATE: blog/index.html.erb --> > <!-- TEMPLATE: blog/_side_bar.html.erb --> > </body> > </html> > > Not having to answer these questions all day would really make my day. > I poked around the rails code for a couple hours and don''t see an > obvious way. Does anyone have an idea on how to do this? > > Thanks! > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Emanuele Tozzato
2009-Apr-03 23:57 UTC
Re: Anyone know a way to create html comments with the names of the views?
*plug-in-ized* and blogged! quick! :) On Fri, Apr 3, 2009 at 10:50 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Emanuele Tozzato
2009-Apr-08 00:54 UTC
Re: Anyone know a way to create html comments with the names of the views?
I''m using it and it''s cool, but it should probably check if any layout statement is present on the controller: if layout is nil then I probably don''t need/want any comment in the template :) (found this with the :tex view of instiki clone) thanks 4 the plugin! On Fri, Apr 3, 2009 at 10:50 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> For what it''s worth i''ve pluginised this: http://github.com/fcheung/tattler/tree/master-- Emanuele Tozzato +1 (619) 549 3230 1985 Sherington Place, #E302 Newport Beach, CA 92663 http://mekdigital.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Apr-08 07:16 UTC
Re: Anyone know a way to create html comments with the names of the views?
On Apr 8, 1:54 am, Emanuele Tozzato <etozz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m using it and it''s cool, but it should probably check if any layout > statement is present on the controller: if layout is nil then I > probably don''t need/want any comment in the template :) >More precisely if what it''s rendering isn''t html it probably shouldn''t be putting html comments in! Fred> (found this with the :tex view of instiki clone) > > thanks 4 the plugin! > > On Fri, Apr 3, 2009 at 10:50 AM, Frederick Cheung > > <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > For what it''s worth i''ve pluginised this:http://github.com/fcheung/tattler/tree/master > > -- > Emanuele Tozzato > +1 (619) 549 3230 > 1985 Sherington Place, #E302 > Newport Beach, CA 92663http://mekdigital.com--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---