[LRUG] Tool to show included partials in RoR?

Jocke Selin jocke at selincite.com
Fri Jan 22 00:50:00 PST 2010


On 21 Jan 2010, at 22:20, Richard Livsey wrote:

> On Thu, Jan 21, 2010 at 3:25 PM, Jocke Selin <jocke at selincite.com> wrote:
>> Hi,
>> 
>> I'm wondering if there's some nice tool that I could point at a file in the app/views/ dir on my machine and it could render, ascii'ally of graphically, which files are "render partial" from there on. I'd like a tree with the file names, that's pretty much all I'd really need.
>> 
>> I know I could write a simple thing to do it, but if there's something out there already I'd rather use that.
> 
> A bit of hacking and I've made a simple gem to do just this.
> 
> $ gem install giraffe
> $ giraffe /path/to/app/views/ graph.png
> 
> It requires graphviz, for more info see the github project:
> http://github.com/rlivsey/giraffe
> 
> It's fairly naive and only works on partials required as strings, but
> you say that's what yours mainly are anyway.
> 
> Hope it does what you want!


Richard,

That's very impressive. I must say. Sadly I hacked my own version yesterday. Not as fancy as yours, though. It just lists templates recursively and indents based on the "depth". 
That was pretty much all I needed; to in some minor graphical way (ASCII in my case) show which template is included from which template. 

However, I do think that what you've done should be part of Rails; If you can generate the DB structure, why can't you generate the structure of Views?! I'm not 100% sure that using an external library should be required though as on my older days I've turned a bit allergic to installing more stuff. Despite that I can see myself installing graphviz just to get a nice "view structure" printed out (I have my DB model taped up on the wall in front of me). :)

If anyone is interested in the little hack I've done, please let me know and I'll happily share. At the moment it works off one template, doesn't take into account shared templates, nor any variable partials etc.

Richard, thanks for your efforts. I'd like to see your efforts going further, sadly I don't really know how to contribute.

Once, again, very cool, and thanks!

/JS


More information about the Chat mailing list