Skip to content

0.2.7 usage mixin

Ivan S Glazunov edited this page Feb 20, 2015 · 2 revisions

Mixin?

Templates.mixin(reconstructor: (...arguments: IArguments) => any) => Content

Mixin have to return something, otherwise it will be considered empty.

var mixin = Templates.mixin;

var mix = mixin(function(a, b, c) {
	return div({ a: a })(b, div()(c));
});

mix(1,2,3).render(console.log);
<div a="1">2<div>3</div></div>

In coffeeScript looks even better.

mixin = Templates.mixin

mix = mixin (a, b, c) -> div(a: a) b, div() c

mix 1, 2, 3
.render console.log
<div a="1">2<div>3</div></div>

Clone this wiki locally