Erector Design Issue: render method names

7 views
Skip to first unread message

Alex Chaffee

unread,
Aug 3, 2011, 3:42:40 PM8/3/11
to erector, Viktor Trón
(Viktor's been hitting some obstacles in the Erector codebase, so
instead of just replying to him on Github I thought I'd
explain/apologize/appeal to the list in a series of Issue Emails.)

Issue: render method names

Erector has had a slew of method names for "put some stuff into a
string". Some are poorly chosen, some are ambiguous, some are
redundant and some are all three! Here's a smattering:

render
_render
_render_via
to_s
to_html
content
capture
text
widget
<< (alias for "append" on String and Erector::Output)

To top it off, Rails also has a method -- actually several -- named "render".

This is totally borked and I want to fix it!!!

The first fix will be to remove "render" from Erector core. So when
you see "render" in source code you'll know you're dealing with
something Rails-y.

But that opens the question of what to call it instead. But that opens
the next can of worms: the different between
(a) appending characters to the output buffer
(b) returning a string from a method call

In the docs I've called this difference *emitting* vs. *returning* so
I suppose I could use "emit" instead of "render".

What I would prefer is to allow "emit" as a synonym for "text" --
since "text" can take all sorts of things now, not just strings -- and
so deprecate/unify "text" and "widget" and "join" into one new awesome
public API method meaning "take these args and emit them".

(This is mostly written, btw, but still called "text" -- see
https://github.com/pivotal/erector/blob/master/lib/erector/text.rb#L5-72
)

--
Alex Chaffee - al...@stinky.com - http://alexch.github.com
Stalk me: http://friendfeed.com/alexch | http://twitter.com/alexch |
http://alexch.tumblr.com

Reply all
Reply to author
Forward
0 new messages