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

Projects
None yet
3 participants
@ddfreyne
Member

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)

This comment has been minimized.

@gregkare

gregkare Nov 9, 2013

Contributor

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

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

gregkare Nov 9, 2013

Contributor

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

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

This comment has been minimized.

@ddfreyne

ddfreyne Nov 9, 2013

Member

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

@ddfreyne

ddfreyne Nov 9, 2013

Member

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

This comment has been minimized.

@bobthecow

bobthecow Nov 10, 2013

Member

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

bobthecow Nov 10, 2013

Member

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

This comment has been minimized.

Show comment
Hide comment
@bobthecow

bobthecow Nov 10, 2013

Member

👍

Member

bobthecow commented Nov 10, 2013

👍

ddfreyne added a commit that referenced this pull request Nov 10, 2013

Merge pull request #348 from nanoc/bug/handlebars-without-layout
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