output buffer returns from beyond the grave...!

2 views
Skip to first unread message

Alex Chaffee

unread,
Oct 5, 2009, 1:22:01 PM10/5/09
to erector
I've been seeing some indentation bugs with nested widgets, especially those that use blocks (call) and/or inline (instance_eval) and I suspect it's due to instance variable confusion. Since the indentation level is an instance var, if the nested widget calls back to a block that was defined in a different widget then it goes back to using the parent widget's indentation level. Anyway, that's my suspicion.

At one point we had a Doc object. We've also experimented with an array of strings. I think that if we bring back Doc and put the indentation on it then we can unravel these problems.

Anyway, just a warning. Anyone think of any pitfalls with going away from a string, and instead wrapping it with an object? The bulk of the code shouldn't change since we'll keep using << to append.

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

Jim Kingdon

unread,
Oct 6, 2009, 11:11:57 PM10/6/09
to ale...@gmail.com, erector
> At one point we had a Doc object. We've also experimented with an array of
> strings. I think that if we bring back Doc and put the indentation on it
> then we can unravel these problems.

Well, I sort of liked Doc (it seemed to have a nicely delimited set of
responsibilities). At least for rails, it seemed to work better to output
to a stream rather than buffer things up, but an object could wrap a
stream (I think that's how Doc worked at the end, but this code went
through enough changes that I won't trust my memory or my ability to
browse it really quickly).

Now, I'm not sure whether this solves your problems with indentation
levels or just provides another place for state to get reset, or not reset
(whichever is least convenient), but I'll leave that to you.


Brian Takita

unread,
Oct 7, 2009, 2:36:45 PM10/7/09
to kin...@panix.com, ale...@gmail.com, erector
The reason for going away from the doc object was Rails compatibility.
Rails uses output_buffer, which is a string. The RailsWidget delegates
output_buffer to the ActionView::Base#output_buffer.

Using an output_buffer makes Rails integration *much* simpler, since
the Rails helpers and Erector widgets are writing to the same buffer.

Alex Chaffee

unread,
Oct 7, 2009, 10:09:34 PM10/7/09
to Brian Takita, kin...@panix.com, erector
Hmm, so just providing a << method wasn't enough? I'm curious what
other problems came up. (Maybe another topic for our elusive pairing
session. )

Sent from my iPhone

On Oct 7, 2009, at 11:36 AM, Brian Takita <brian....@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages