Fix handlebars crash when used outside layout

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