【问题标题】:unexpected error using yield in haml nesting在haml嵌套中使用yield出现意外错误
【发布时间】:2016-06-26 07:19:14
【问题描述】:

服务器日志:

Processing by GamesController#index as HTML
  Rendered games/index.haml within layouts/games (0.1ms)
Completed 500 Internal Server Error in 6ms (ActiveRecord: 0.0ms)

截断的布局是:

  %body
    = render partial: '/layouts/gamescreen/viewport'
      = yield

部分 games.haml 内容是单个 Haml div:

  #viewport

产生的观点是:

  Hi!

产生的错误信息:

  /home/ubuntu/workspace/app/views/layouts/games.haml:12: syntax error, unexpected keyword_ensure, expecting end-of-input

【问题讨论】:

    标签: ruby-on-rails haml yield


    【解决方案1】:

    我相信answer for this question "Rails render partial with block" 拥有解决方案。

    在你的布局中你会使用

    = render layout: '/layouts/gamescreen/viewport' do 
      Hi!
    

    在你的 layouts/gamescreen/viewport 部分,你会有

    = yield
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-19
      • 1970-01-01
      • 2013-10-20
      相关资源
      最近更新 更多