Skip to content

0.2.7 usage context

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

Context?

Context - the object that is passed to a post-processor Templates._stringTemplate.

By default - wrap around method _.template.

Processing occurs automatically when .rendering.

The context may be specified for each element separately using the method Templates.context.

Contexts overlap.

div()(
	'<%= c1 %>',
	div()('<%= c1 %>'),
	div()('<%= c1 %>').context({ c1: 2 }),
	div()('<%= c1 %>').context({ c1: 2 }).render({ c1: 3 }),
	div()('<%= c1 %>').render({ c1: 4 }),
).render({ c1: 1 }, function(result) {
	console.log(result);
});
<div>1<div>1</div><div>2</div><div>3</div><div>4</div></div>
Clone this wiki locally