transparency.js嵌套普通值

时间:2012-12-21 17:07:58

标签: javascript coffeescript template-engine transparency.js

我想知道以下为什么不起作用:

CoffeeScript的:

post =
  title:    'Hello World',
  post:     'Hi there it is me',
  comments: [
    name: 'John',
    text: 'That rules'
  ,
    name: 'Arnold',
    text: 'Great post!',
    tags: ['a', 'b', 'c']
  ]

directives =
  tags:
    tag: 
      text: (target) -> this.value


$('.container').render post, directives

模板:

<div class="container">
  <h1 class="title"></h1>
  <p class="post"></p>
  <div class="comments">
    <div class="comment">
      <span class="name"></span>
      <span class="text"></span>
      <div class="tags">
        <span class='tag'></span>
      </div>
    </div>
  </div>
</div>

它不呈现嵌套的普通标签,也不会为它们执行指令功能

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

这是正确的指令集:

directives =
  comments:
    tags:
      tag:
        text: (target) -> this.value

指令不会像正常值那样跳过未提及的顶层,因此您必须包含comments层。