Skip to content

Expose `$mixins` var within template functions

Compare
Choose a tag to compare
@tdumitrescu tdumitrescu released this 20 Feb 22:43
· 47 commits to master since this release

Within code blocks in your template code, you can now access Jade mixin functions via the $mixins variable. In virtual-jade, mixins boil down to functions that take arguments and return a tree of h(name, attrs, children). They are like React stateless components. Accessing them via $mixins is useful for special cases where you want to pass around handles to blocks of Jade code as callback functions, e.g.:

mixin item(x)
  .item
    .more-tree= x + 1

list-virtual-scroll(props={itemRenderer: $mixins.item})
// in list-virtual-scroll.jade
each val in allItems.slice(startIdx, endIdx)
  = props.itemRenderer(val)