如何在玉模板中使用else语句?

用户名

是node.js的新功能。我已经使用express生成了一个简单的网站。我在中添加了以下文本index.jade

raining = true
if(raining === true)    
    p It is raining. Take an umbrella!
else  
    p No rain. Take the bike!

当我注释掉最后两个语句时,得到了预期的响应:“正在下雨。请撑伞!”

当我包含最后两行时,出现意外的令牌错误:

Unexpected token (57:0)

SyntaxError: Unexpected token (57:0)
at Parser.pp.raise (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:943:13)
at Parser.pp.unexpected (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:1503:8)
at Parser.pp.parseExprAtom (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:327:12)
at Parser.pp.parseExprSubscripts (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:216:19)
at Parser.pp.parseMaybeUnary (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:197:19)
at Parser.pp.parseExprOps (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:151:19)
at Parser.pp.parseMaybeConditional (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:133:19)
at Parser.pp.parseMaybeAssign (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:110:19)
at Parser.pp.parseExpression (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:86:19)
at Parser.pp.parseStatement (/home/ubuntu/workspace/node_modules/jade/node_modules/with/node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:1750:23)

不知道为什么包含else语句会导致错误。任何建议将不胜感激。

赫尔曼·安德烈斯·菲格罗亚

注意缩进:

这是一个例子

http://jsfiddle.net/heanfig/z8wn5qz9/

查玉参考

http://learnjade.com/tour/conditionals/

- var raining = true
if raining == true
        p It is raining. Take an umbrella!
else
        p No rain. Take the bike!

甚至:

| #{raining ? raining : 'man'}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在Django模板中使用“ for”语句

来自分类Dev

如何在ActionSheet中使用if / else语句?

来自分类Dev

玉模板if语句

来自分类Dev

玉模板if语句

来自分类Dev

如何在Django中使用if语句编写更好的模板逻辑?

来自分类Dev

Django - 如何在 if 语句中使用模板标签

来自分类Dev

如何在MySQL中使用JOIN编写适当的If ... Else语句?

来自分类Dev

如何在访问器中使用if-else语句?

来自分类Dev

Rails –如何在数组中使用if else语句?

来自分类Dev

如何在反应中使用if else语句验证RegExp?

来自分类Dev

如何在标准Bigquery中使用if-else语句?

来自分类Dev

如何在熊猫数据框中使用If Else语句?

来自分类Dev

如何在Perl中使用else单行语句?

来自分类Dev

如何在if-else语句中使用for循环

来自分类Dev

如何在访问器中使用if-else语句?

来自分类Dev

如何在批处理编程中使用if-else语句?

来自分类Dev

Rails –如何在数组中使用if else语句?

来自分类Dev

如何在Java脚本if / else语句中使用HTML?

来自分类Dev

如何在Selenium IDE中使用if / else语句

来自分类Dev

如何在echo语句中使用if和else?

来自分类Dev

如何在生产中将html(玉模板)更改为使用* .min js和css?

来自分类Dev

在模板中使用or语句

来自分类Dev

如何在带有nunjucks的Express框架中使用HTML-无玉

来自分类Dev

如何在模板if语句中使用Django翻译的变量(trans)

来自分类Dev

如何在Django模板的条件语句中使用字典中的值进行操作

来自分类Dev

如何在模板if语句中使用Django翻译的变量(trans)

来自分类Dev

如何在python 2.7中使用内联if else语句单行打印

来自分类Dev

如何在if循环中使用if else语句创建新列?

来自分类Dev

如何在asp.net的DataBinder.Eval中使用IF ELSE语句

Related 相关文章

  1. 1

    如何在Django模板中使用“ for”语句

  2. 2

    如何在ActionSheet中使用if / else语句?

  3. 3

    玉模板if语句

  4. 4

    玉模板if语句

  5. 5

    如何在Django中使用if语句编写更好的模板逻辑?

  6. 6

    Django - 如何在 if 语句中使用模板标签

  7. 7

    如何在MySQL中使用JOIN编写适当的If ... Else语句?

  8. 8

    如何在访问器中使用if-else语句?

  9. 9

    Rails –如何在数组中使用if else语句?

  10. 10

    如何在反应中使用if else语句验证RegExp?

  11. 11

    如何在标准Bigquery中使用if-else语句?

  12. 12

    如何在熊猫数据框中使用If Else语句?

  13. 13

    如何在Perl中使用else单行语句?

  14. 14

    如何在if-else语句中使用for循环

  15. 15

    如何在访问器中使用if-else语句?

  16. 16

    如何在批处理编程中使用if-else语句?

  17. 17

    Rails –如何在数组中使用if else语句?

  18. 18

    如何在Java脚本if / else语句中使用HTML?

  19. 19

    如何在Selenium IDE中使用if / else语句

  20. 20

    如何在echo语句中使用if和else?

  21. 21

    如何在生产中将html(玉模板)更改为使用* .min js和css?

  22. 22

    在模板中使用or语句

  23. 23

    如何在带有nunjucks的Express框架中使用HTML-无玉

  24. 24

    如何在模板if语句中使用Django翻译的变量(trans)

  25. 25

    如何在Django模板的条件语句中使用字典中的值进行操作

  26. 26

    如何在模板if语句中使用Django翻译的变量(trans)

  27. 27

    如何在python 2.7中使用内联if else语句单行打印

  28. 28

    如何在if循环中使用if else语句创建新列?

  29. 29

    如何在asp.net的DataBinder.Eval中使用IF ELSE语句

热门标签

归档