【问题标题】:Using Jade in Meteorjs在 Meteorjs 中使用 Jade
【发布时间】:2015-07-31 00:59:54
【问题描述】:

我正在研究 Meteor in action 这本书,书中作者使用 html/js,但我更喜欢玉/咖啡。这段代码我遇到了一些麻烦:

<template name="templateElseBlock">
  <h3>templateElseBlock template</h3>
  {{#isFemale gender}} Mrs. {{else}} Mr. {{/isFemale}}
</template>

<template name="isFemale">
  {{#if eq this 'w'}}
    {{> Template.contentBlock}}
  {{else}}
    {{> Template.elseBlock}}
  {{/if}}
</template>

我尝试过这样的事情,但只有错误

 While building the application:
   client/main.jade: Jade syntax error: unexpected token "indent"
   <runJavaScript-57>:73:14: Cannot read property 'head' of undefined
   (compiling client/main.jade) (at fileModeHandler)


template(name='templateElseBlock')
  isFemale gender
    | Mrs.
  else
    | Mr.

template(name="isFemale")
  if eq #{this} 'w'
    +Template.contentBlock
  else
    +Template.elseBlock

有人知道该怎么做吗?

【问题讨论】:

  • 请说明您有哪些错误
  • 我在上面写了我得到的整个错误

标签: meteor pug spacebars


【解决方案1】:

经过几个谷歌页面后,我发现代码只需要一个符号 +isFemale。

答案:

template(name='elseBlock')
  +isFemale gender
    | Mrs.
  else
    | Mr.


  template(name="isFemale")
    if eq this 'w'
     +Template.contentBlock
    else
     +Template.elseBlock

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-12
    • 1970-01-01
    • 2012-10-20
    • 1970-01-01
    • 1970-01-01
    • 2012-01-21
    • 2014-12-12
    • 1970-01-01
    相关资源
    最近更新 更多