flatiron / plates

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

Quirky behavior for tags that have multiple classes #91

Open natesilva opened 11 years ago

natesilva commented 11 years ago

Using Plates 0.4.8, it seems that tags with multiple class names can make mappings fail.

Here I’ve tried to bind the href attribute of an <a> tag. It works, but only if the tag has just one class name. If the tag has multiple class names, it fails.

var Plates = require('plates');

var html = '<a class="class1 class2" href="#">Foo</a>';
var data = { 'url': 'http://google.com/' };

// *** TEST 1
// doesn't work at all
var map1 = Plates.Map();
map1.class('class1').use('url').as('href');
console.log(Plates.bind(html, data, map1));

// *** TEST 2
// remove the "as" clause
// result: does something but not what I want it to do
var map2 = Plates.Map();
map2.class('class1').use('url');
console.log(Plates.bind(html, data, map2));

// *** TEST 3
// remove the additional class name
// result: works, but I had to get rid of a class that I might want
html = '<a class="class1" href="#">Foo</a>';
var map3 = Plates.Map();
map3.class('class1').use('url').as('href');
console.log(Plates.bind(html, data, map3));
henriknorberg commented 11 years ago

Got the same problem, had to use ID get around it.

tizzo commented 11 years ago

Same here.