mixin.attrs.pug 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. mixin centered(title)
  2. div.centered(id=attributes.id)
  3. - if (title)
  4. h1(class=attributes.class)= title
  5. block
  6. - if (attributes.href)
  7. .footer
  8. a(href=attributes.href) Back
  9. mixin main(title)
  10. div.stretch
  11. +centered(title).highlight&attributes(attributes)
  12. block
  13. mixin bottom
  14. div.bottom&attributes(attributes)
  15. block
  16. body
  17. +centered#First Hello World
  18. +centered('Section 1')#Second
  19. p Some important content.
  20. +centered('Section 2')#Third.foo(href='menu.html', class='bar')
  21. p Even more important content.
  22. +main('Section 3')(href='#')
  23. p Last content.
  24. +bottom.foo(class='bar', name='end', id='Last', data-attr='baz')
  25. p Some final words.
  26. +bottom(class=['class1', 'class2'])
  27. mixin foo
  28. div.thing(attr1='foo', attr2='bar')&attributes(attributes)
  29. - var val = '<biz>'
  30. - var classes = ['foo', 'bar']
  31. +foo(attr3='baz' data-foo=val data-bar!=val class=classes).thunk
  32. //- Regression test for #1424
  33. mixin work_filmstrip_item(work)
  34. div&attributes(attributes)= work
  35. +work_filmstrip_item('work')("data-profile"='profile', "data-creator-name"='name')
  36. mixin my-mixin(arg1, arg2, arg3, arg4)
  37. p= arg1
  38. p= arg2
  39. p= arg3
  40. p= arg4
  41. +foo(
  42. attr3="qux"
  43. class="baz"
  44. )
  45. +my-mixin(
  46. '1',
  47. '2',
  48. '3',
  49. '4'
  50. )