trailblazer/cells

Consider documenting the existence of escape!()?

Opened this issue · 2 comments

In upgrading from 3 to 4 (cells seems to be the most changeable gem I've ever worked with, and I've been using it for a long time :)), I was a bit disconcerted about not having the ability to arbitrarily escape things in the view until I discovered escape! tucked in the end of Escaped.

Would you consider documenting that, or are you not wanting to draw attention to escaping in this way?

I would love to use the property escapers but in a cell view that I'm upgrading, the model has many sub-things that I'm rendering too. I suppose I should have a cell for the sub-things with properties and all that, but it seems like overkill for what I'm trying to output. There's no other way to escape the properties of a sub-model?

I agree that this should be documented. (It's worth noting for anyone else reading this that the escape! method isn't available unless you include Escaped into the Cell.)

I find it's fairly common that I need to escape a string that can't be neatly encapsulated within a property. Yes, this is probably a sign that I should split out an entirely new 'sub cell', but as we all know, sometimes you have to sacrifice perfect design for the sake of getting things done fast.

Note that all escape!(string) does is call ERB::Util.html_escape(string), so you can always just use ERB::Util directly if you don't want to depend on escape!.

Indeed @georgemillo, I think I may have resorted to html_escape on one occasion also. If I remember correctly, the process of upgrading to Cells 4 was quite a positive learning experience once I got my head around the changes. :)