Added numeric ability for text nodes. #470

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@bobbytables

I discovered that table_for (and any tag really) created with Arbre with the content of a numeric value would just not display anything. For example:

table_for(article) do
  column("Article Comments") { |a| a.comments_count }
end

The column for comments will be blank because "comments_count" is a number.
The code in builder.rb prevents this on this line:

if tag.is_a?(String)
  current_dom_context << Arbre::HTML::TextNode.from_string(tag)
end

I added spec but wasn't sure if it was to par, sorry if isn't.

@ebeigarts

This comment has been minimized.

Show comment Hide comment
@ebeigarts

ebeigarts Sep 23, 2011

Contributor

This has been already reported in #154 and it also accepts any object that has to_s method.

Contributor

ebeigarts commented Sep 23, 2011

This has been already reported in #154 and it also accepts any object that has to_s method.

@ghost ghost assigned gregbell Jan 11, 2012

gregbell added a commit that referenced this pull request Jan 11, 2012

Add any object that repsonds to to_s to the DOM in Arbre blocks.
Before this commit:

  index do
    column("My Column"){ 1 }
  end

Would result in an empty column. Now the object is appended to the DOM
and will result in a colum of "1"s.

The return value is ignored if the user has already appended other
elements to the DOM. This might trip up some users, however it is more
likely that you are either going to build up a DOM structure or return a
simple value, not both.

Thanks for the pull requests from @bobbytables and @utkarshkukreti

References isses #470, 154
@gregbell

This comment has been minimized.

Show comment Hide comment
@gregbell

gregbell Jan 11, 2012

Contributor

Fixed on master in 9cb2b90

Contributor

gregbell commented Jan 11, 2012

Fixed on master in 9cb2b90

@gregbell gregbell closed this Jan 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment