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

Fix handlebars crash when used outside layout #348

Merged
merged 1 commit into from Nov 10, 2013

Conversation

denisdefreyne
Copy link
Member

The handlebars filter assumes the presence of attributes[:layout], which is not the case when used outside a layout.

This fixes #346.

context[:config] = assigns[:config]
context[:yield] = assigns[:content]
if assigns.has_key?(:layout)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like using one-liners in cases like this, what do you think?

context[:layout] = assigns[:layout].attributes if assigns.has_key?(:layout)

Copy link
Member Author

Choose a reason for hiding this comment

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

I’m not a fan of one-line if statements because they tend to be overlooked too easily.

Copy link
Member

Choose a reason for hiding this comment

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

i'm with @ddfreyne here. one-line ifs make sense for things like

return if assigns.has_key?(:layout)

or

raise "Error, yo" unless assigns.has_key?(:layout)

... but not for assignment :)

@bobthecow
Copy link
Member

👍

denisdefreyne added a commit that referenced this pull request Nov 10, 2013
Fix handlebars crash when used outside layout
@denisdefreyne denisdefreyne merged commit f56e9b6 into release-3.6.x Nov 10, 2013
@denisdefreyne denisdefreyne deleted the bug/handlebars-without-layout branch November 10, 2013 14:56
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.

None yet

3 participants