New naming scheme for Rails Partials?
March 11, 2008
I personally dislike the current naming scheme of partials. Right now they follow the format of _somepartial.html.erb (Rails 2.*). I find it rather distracting and hard to find what I want when I am in a directory full of partial files following that naming format.
My suggestion is to use .perb for partials. I think files like somepartial.html.perb would be much more pleasant to look at, a kind of syntax sugar to encourage more usage of partials perhaps. Also, I think it would be a more consistent naming scheme.
Vote for somepartial.html.perb ;)
Filed under: Everything | Comments (4)
I agree with the notion that the underscore prefix for partials is kind of sucky (although I’ve gotten used to it) but I disagree with the suggestion to shift it to the last part of the filename (e.g. perb). For me it just feels like it voids the purpose (well, to a degree atleast) of using the .. syntax.
To be honest, I think a seperate partials folder (which it looks in automatically) would be a better idea but even that has flaws.
pbuilder? phaml? prjs? This does not scale!
What about somepartial.partial.html.erb? One more extension couldn’t hurt!
Good point Tim.
Lets make the extension smaller though, ‘ptl’ seems good to me.
somepartial.ptl.html.erb could work.
But that makes me wonder, why is .erb on the end in the first place? Most editors syntax highlight based on the last extension.
Seems like somepartial.ptl.erb.html would make more sense.
Why have any special naming scheme at all? Why treat partials differently at all? I’ve never understood this.