【问题标题】:Yield and contentFor in meteor-jade with iron-router流星玉配铁路由器的产量和含量
【发布时间】:2015-08-31 05:03:43
【问题描述】:

我想用 {{>yield "aside"}}{{#contentFor "aside"}}{{/contentFor}} 在翡翠中使用流星和铁路由器,但我收到了这个错误:

Jade syntax error: unexpected token "indent" <runJavaScript-59>:73:14: Cannot read property 'head' of undefined (at fileModeHandler)

它有什么问题? 与这些标签等效的空格键在翡翠中的正确语法是什么?

非常感谢!

【问题讨论】:

    标签: node.js meteor pug iron-router


    【解决方案1】:

    我想通了

    +contentFor("aside")
        p Hello World
    

    【讨论】:

      【解决方案2】:

      编辑:

      所以在你的路由器中,如果你做这样的事情:

      Router.route('/some-route', function () {
      
        this.render('SomeRouteTemplate' {
          data: function () { return 'some data' }
        });
      
        this.render('MyTemplate', {
          to: 'aside',
          data: function () { return 'some data' }
        });
      
      });
      

      这应该在布局模板的侧面区域呈现您的 MyTemplate 并将所需的任何数据传递给模板:

      template(name="layout")
      
        +yield(region="aside")
      

      【讨论】:

      • 嗯错误不在这个文件上,它出现在这个标签上:{{#contentFor "aside"}} My Text {{/contentFor}}
      • 我不太清楚你的意思。您能否更详细地描述您想要实现的目标?
      • 好的,所以,我有一个 ApplicationLayout,带有这个标签:{{>yield "aside"}} 我不想从 MyTemplate 填充它(我的 RouteController 加载的模板,它从 ApplicationLayout “继承” ) 通过使用此标签:{{#contentFor "aside"}} My Text {{/contentFor}}
      • 好的,我已经更新了我的答案。希望这可以为您解决一些问题。
      猜你喜欢
      • 2017-08-15
      • 2014-09-03
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 2014-06-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多