Skip to content

Instantly share code, notes, and snippets.

@BananaAcid
Last active April 20, 2018 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BananaAcid/d80fb9dde601b5d786e54376769727a2 to your computer and use it in GitHub Desktop.
Save BananaAcid/d80fb9dde601b5d786e54376769727a2 to your computer and use it in GitHub Desktop.
PUG (Jade) Mixins
//-
PhpStorm 2018.1 shows multiple errors and is not able to handle this fully valid PUG mixin
mixin test(param1, param2 = "test", optionalParam3)
- var xOptionalParam3 = optionalParam3 || "is none";
<!{param1}> !{param2} => !{xOptionalParam3} </!{param1}>
//-
Nested use of mixins with params and content block!
//-
<div><span>a</span>:<em>some content</em></div>
mixin test(val)
div
span= val
| :
em
block
+test("a")
| some content
//-
<ol>
<li>EMPTY! (abc)</li>
<li>default item (def)</li>
<li>new... (ghi)</li>
</ol>
mixin ArrayList()
ol
| #[block]
mixin ArrayListItemPlaceholder()
li EMPTY! (#[block])
mixin ArrayListItem()
li default item (#[block])
mixin ArrayListItemNew()
li new... (#[block])
+ArrayList()
+ArrayListItemPlaceholder()
| abc
+ArrayListItem()
| def
+ArrayListItemNew()
| ghi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment