Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use layout.build instead of layout.new #432

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JelF
Copy link

@JelF JelF commented Oct 26, 2016

Use layout.build instead of layout.new in Cell::ViewModel::Layout::External.

Reason: allow layout class to be selected using context.
I.e. builds { |_, context:, **| self::Mobile if context[:mobile] }

@apotonick
Copy link
Member

That's brilliant! But no test? 😭

@JelF
Copy link
Author

JelF commented Oct 27, 2016

@apotonick should i place it in builder_test or in layout_test?

@apotonick
Copy link
Member

@JelF Thanks, into layout test, please. @timoschilling what do you think about this?

@timoschilling
Copy link
Contributor

@apotonick There is no performance Problem, if you mean this? If the cell don't include Cell::Builder, build is just an alias for new and calling a alias coast the same as calling the original. This PR unifies the API of a normal cell and a layout cell, so I give it a thumbs up!

@apotonick
Copy link
Member

✋ <-- :highfive:

@JelF JelF force-pushed the use-build-instead-of-new-for-layouts branch from 1ea5067 to bbe8eec Compare November 2, 2016 07:41

it 'renders special layout if requested' do
Comment::ShowCell.new(nil, layout: Comment::LayoutCell, context: { special_layout: true }).
().must_equal "$layout.erb{Comment::SpecialLayoutCell, $show.erb, {:special_layout=>true}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't sure it's the best way to handle multiline strings. Should i better use heredoc and gsub extra spaces?

in Cell::ViewModel::Layout::External.

Reason: allow layout class to be selected using context.
I.e. builds { |_, context:, **| self::Mobile if context[:mobile] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants