I just started checking out WordPress’ CSS Architecture to study a system that’s established and pretty powerful to learn better HTML habits. I’ve noticed they use all hyphens - (post-554 for example), while Rails uses underscores _ (post_554 for example). I’m wondering if there’s some setting to customize this in Rails, something like ActionView::Template.word_boundary = "-".
Is there? Not that it really matters, just trying to learn why people do things the way they do.
🙂
You can’t change se separator. It is hard-coded into Rails.
For example, post_554 is generated by the
dom_idhelper, which internally relies on theRecordIdentifierclass.Here’s the definition.
The separator, the
JOINconstant, is defined as freezed String so you can’t change it.There are two ways to change it:
There are also some technical restrictions that explain the reason behind this choice, mainly tied to the language behind Rails.
For instance, talking about symbols
Using
-would probably require a less cleaner approach to Ruby.Personally, I prefer using
-rather than_and I tend to avoid standard Rails helpers unless strictly required.