Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Anyone know a way to create html comments with the names of the views?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
mixtli  
View profile  
 More options Apr 3, 9:06 am
From: mixtli <ronmcclai...@gmail.com>
Date: Fri, 3 Apr 2009 06:06:36 -0700 (PDT)
Local: Fri, Apr 3 2009 9:06 am
Subject: 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!


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frederick Cheung  
View profile  
 More options Apr 3, 10:07 am
From: Frederick Cheung <frederick.che...@gmail.com>
Date: Fri, 3 Apr 2009 07:07:30 -0700 (PDT)
Local: Fri, Apr 3 2009 10:07 am
Subject: Re: Anyone know a way to create html comments with the names of the views?

On Apr 3, 2:06 pm, mixtli <ronmcclai...@gmail.com> 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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
emanuele tozzato  
View profile  
 More options Apr 3, 10:14 am
From: emanuele tozzato <etozz...@gmail.com>
Date: Fri, 3 Apr 2009 07:14:24 -0700
Local: Fri, Apr 3 2009 10:14 am
Subject: Re: [Rails] 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 <ronmcclai...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mixtli  
View profile  
 More options Apr 3, 10:50 am
From: mixtli <ronmcclai...@gmail.com>
Date: Fri, 3 Apr 2009 07:50:34 -0700 (PDT)
Local: Fri, Apr 3 2009 10:50 am
Subject: 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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mixtli  
View profile  
 More options Apr 3, 11:11 am
From: mixtli <ronmcclai...@gmail.com>
Date: Fri, 3 Apr 2009 08:11:10 -0700 (PDT)
Local: Fri, Apr 3 2009 11:11 am
Subject: 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.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frederick Cheung  
View profile  
 More options Apr 3, 1:50 pm
From: Frederick Cheung <frederick.che...@gmail.com>
Date: Fri, 3 Apr 2009 18:50:29 +0100
Local: Fri, Apr 3 2009 1:50 pm
Subject: Re: [Rails] 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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Philip Hallstrom  
View profile  
 More options Apr 3, 1:53 pm
From: Philip Hallstrom <phi...@pjkh.com>
Date: Fri, 3 Apr 2009 10:53:58 -0700
Local: Fri, Apr 3 2009 1:53 pm
Subject: Re: [Rails] 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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Julian Leviston  
View profile  
 More options Apr 3, 2:28 pm
From: Julian Leviston <jul...@coretech.net.au>
Date: Sat, 4 Apr 2009 05:28:57 +1100
Local: Fri, Apr 3 2009 2:28 pm
Subject: Re: [Rails] 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 <ronmcclai...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Emanuele Tozzato  
View profile  
 More options Apr 3, 7:57 pm
From: Emanuele Tozzato <etozz...@gmail.com>
Date: Fri, 3 Apr 2009 16:57:18 -0700
Local: Fri, Apr 3 2009 7:57 pm
Subject: Re: [Rails] 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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Emanuele Tozzato  
View profile  
 More options Apr 7, 8:54 pm
From: Emanuele Tozzato <etozz...@gmail.com>
Date: Tue, 7 Apr 2009 17:54:18 -0700
Local: Tues, Apr 7 2009 8:54 pm
Subject: Re: [Rails] 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.che...@gmail.com> 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

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Frederick Cheung  
View profile  
 More options Apr 8, 3:16 am
From: Frederick Cheung <frederick.che...@gmail.com>
Date: Wed, 8 Apr 2009 00:16:04 -0700 (PDT)
Local: Wed, Apr 8 2009 3:16 am
Subject: Re: Anyone know a way to create html comments with the names of the views?

On Apr 8, 1:54 am, Emanuele Tozzato <etozz...@gmail.com> 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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google