flatiron / plates

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

Option to allow/disallow undefined attributes #95

Closed johngeorgewright closed 9 years ago

johngeorgewright commented 11 years ago

Hey there,

I've found the option to create attributes when they don't already exists... however, is there any option to allow/disallow undefined attributes?

For example:

var plates    = require('plates'),
    itemPlate = '<li class="menu-item"></li>',
    data      = [],
    html      = '',
    map;

data.push({
  content : 'item 1',
  id      : 'item-1'
});

data.push({
  content : 'item 2'
});

map = new plates.Map({
  create : true
});

map
  .className('menu-item')
  .to('content')
  .className('menu-item')
  .use('id').as('id');

html = plates.bind(itemPlate, data, map);

console.log(html);
// <li class="menu-item" id="item-1">item 1</li><li class="menu-item" id="">item 2</li>

As you can see, I don't really want the id attribute to exist in the 2nd item. I imagine in some cases I might want the attribute to exists and be empty, but not in this one.

Ta, John

johngeorgewright commented 9 years ago

Closing... been open for a few years.