Skip to content

Instantly share code, notes, and snippets.

@nashibao
Last active January 31, 2016 11:07
Show Gist options
  • Save nashibao/7889825 to your computer and use it in GitHub Desktop.
Save nashibao/7889825 to your computer and use it in GitHub Desktop.
jade mixins for knockout.js virtual element. https://github.com/visionmedia/jade/pull/958
mixin with(val)
<!-- ko with: !{val} -->
block
<!-- /ko -->
mixin if(val)
<!-- ko if: !{val} -->
block
<!-- /ko -->
mixin each(val)
<!-- ko foreach: !{val} -->
block
<!-- /ko -->
@nashibao
Copy link
Author

  • how to use the snippet.
+with('vm')
  #name(data-bind="text: name")

will be compiled to..

<!-- ko with: vm -->
<div id="name" data-bind="text: name"></div>
<!-- /ko -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment