leonidas / transparency

Transparency is a semantic template engine for the browser. It maps JSON objects to DOM elements by id, class and data-bind attributes.
http://leonidas.github.com/transparency/
MIT License
969 stars 112 forks source link

Rendering attributes on a "parent" element fails. #85

Closed mtkopone closed 11 years ago

mtkopone commented 11 years ago

Hi,

Maybe I'm not doing it right, but I figured something like this should work:

var thing = {
  link: {
    name: 'MyLink',
    description: 'takes me somewhere'  
  }
}
var directives = { 
  link: { href: function(params) { return 'http://doesnt-render.com/' } }
}
$('.container').render(thing, directives)
<div class="container">
  <a class="link"><span class="name"/><span class="description"/></a>
</div>

So I'm trying to add the href-attribute to the parent element, but it fails with "Directive syntax is directive[element][attribute] = function(params)"

Any help is appreciated.

pyykkis commented 11 years ago

D'oh, that was a bug. Validation for directives was too strict. The example you provided is completely valid and works now.