the #h method actully allready exists in rails, and is quite widely
used.
Awesome, I'm switching all of my code over to use that and #u now.
obj#method! is a method that will cause obj to be modified or
something potentially harmful/irreversable.
obj#method? will return a boolean [true/false] value
Yes... so here's why I went for using "!" anyway... I discovered this
today (keep in mind I've only been rubying for about a month now) and it
made me jump for joy...
When a method ends with punctuation, you dont have to put a space between
a method name and the arguments!!!
That's why I decided to futz with something like "h~"... To me,
<%=h~email_address%>
or even
<%=h!email_address%>
Looks way neater than
<%=h email_address%>
Especially when you start stacking them, like:
<script>
document.location="/foo?params=" . <%=h!j!u!url_fragment%>
</script>
What would be really nice is if there were a few other symbols available
for method suffixing... I think "~" would be a nice one... I'd take that to
mean "perform a match or transformation on the data to my right", but that's
probably because I'm coming from the perl world where "=~" is the regular
expression operator... "h~j~u~url_fragement" would be a darn cool way to
express that url_fragement is being modified by "h", "j", and "u" on it's
way out to you... or stuff like:
ip_address = dns~hostname
on a pointless note: if you wanted #h~ open irb and try....
self.class.send(:define_method, :"h~") {string_esacpe_html}
this is a ruby-is-fun example... and completly pointless as you'd have
to call it via #send
Geeze.
Well, thanks both of you (chris and rimantas) for sorting me out. Now I
have to decide if I'm going to keep the bang on the end of my homecooked
transformers... that's a touch one...
Thanks,
Tyler