Skip to content

Instantly share code, notes, and snippets.

@markhalliwell
Last active August 29, 2015 14:03
Show Gist options
  • Save markhalliwell/64bf26914d5f5304df39 to your computer and use it in GitHub Desktop.
Save markhalliwell/64bf26914d5f5304df39 to your computer and use it in GitHub Desktop.
{% attributes.class.add([
'node',
'node--type-' ~ node.bundle|class,
node.promoted ? 'node--promoted',
node.sticky ? 'node--sticky',
not node.published ? 'node--unpublished',
preview ? 'node--preview',
'node--view-mode-' ~ view_mode|class
]).remove([
'some-module-class'
]) %}
<article {{attributes}}>
vs.
{% set classes = [
'node',
'node--type-' ~ node.bundle|class,
node.promoted ? 'node--promoted',
node.sticky ? 'node--sticky',
not node.published ? 'node--unpublished',
preview ? 'node--preview',
'node--view-mode-' ~ view_mode|class
]
%}
<article class="{{ attributes.class.add(classes).remove(['some-module-class']) }}"{{ attributes|without('class') }}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment