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

@ddfreyne
Copy link
Member

@ddfreyne ddfreyne commented Nov 9, 2013

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

@gregkare gregkare Nov 9, 2013

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)

Loading

Copy link
Member Author

@ddfreyne ddfreyne Nov 9, 2013

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.

Loading

Copy link
Member

@bobthecow bobthecow Nov 10, 2013

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 :)

Loading

@bobthecow
Copy link
Member

@bobthecow bobthecow commented Nov 10, 2013

👍

Loading

ddfreyne added a commit that referenced this issue Nov 10, 2013
Fix handlebars crash when used outside layout
@ddfreyne ddfreyne merged commit f56e9b6 into release-3.6.x Nov 10, 2013
@ddfreyne ddfreyne deleted the bug/handlebars-without-layout branch Nov 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants