【问题标题】:Meteor-Jade and object literals?Meteor-Jade 和对象字面量?
【发布时间】:2016-08-23 22:03:18
【问题描述】:

我在 Meteor 中使用 Jade,想在 EasySearch.Input 中设置一个占位符,如下所示:

+EasySearch.Input(index=objects_index attributes={placeholder: 'sample'})

至少文档是这样建议的:

属性:包含输入属性的对象(例如 { placeholder: "Search..." })

我以天真的方式尝试了这个,客户端崩溃了:

 While processing files with mquandalle:jade (for target web.browser):
 client/objlist.jade: Jade syntax error: Expected IDENTIFIER
 ...ch.Input attributes=('placeholder': 'samp...
                    ^
 client/objlist.jade: Jade syntax error: Cannot read property 'head' of undefined

我尝试了来自 github 问题的解决方案:

+EasySearch.Input(attributes="{{{placeholder: 'sample'}}}" index=objects_index)

还是不行。

html.js:232 未捕获错误:非法 HTML 属性名称:0

我应该发布一个变量还是为此创建另一个助手?

【问题讨论】:

    标签: meteor pug


    【解决方案1】:

    你需要用 bang 和 tildes 来逃避这个:

    attributes!= `{placeholder: 'sample'}`
    

    这告诉 pug 使用未转义的文字表达式。

    【讨论】:

      猜你喜欢
      • 2014-09-03
      • 1970-01-01
      • 2010-11-09
      • 2013-02-22
      • 2012-03-27
      • 2013-04-26
      • 2011-09-07
      • 2016-02-09
      • 1970-01-01
      相关资源
      最近更新 更多