flatiron / plates

Light-weight, logic-less, DSL-free, templates for all javascript environments!
MIT License
831 stars 69 forks source link

Partials #102

Open me-ascii opened 11 years ago

me-ascii commented 11 years ago

Have a trouble with data mapping if used partials. It can be illustrated on expamle from your README.md

var partial = '<li class="partial"></li>';
var base = '<div><h1 class="foo"></h1><ul class="menu"></ul></div>';

var baseData = { foo: 'bar' };
var mapping = Plates.Map();

mapping.class('menu').append(partial);
console.log(Plates.bind(base, baseData, mapping));

Results is:

<div><h1 class="foo"></h1><ul class="menu"><li class="partial"></li></ul></div>

foo = 'bar' was not rendered!

me-ascii commented 11 years ago

I found that only html of partials mapped by baseData in the .bind (not base that passed in the args). https://github.com/flatiron/plates/blob/master/lib/plates.js#L350

So when foo moved to the partial

var partial = '<li class="partial"><p class="foo"></p></li>',

Bind returns

<div><h1 class="foo"></h1><ul class="menu">
<li class="partial"><p class="foo">bar</p></li></ul></div>

As found this issue refers to the https://github.com/flatiron/plates/issues/76