html - 使用 Sinatra 布局生成模板 : Yields stringified version of my html

标签 html templates sinatra yield

在 sinatra 框架内,我试图在布局模板:layout.haml 中生成一个模板,dashboard.haml。但是当页面加载时,会出现 html 的字符串化版本,而不是 HTML 本身。所以它显然获取了正确的模板,但我想知道为什么 html 被渲染为字符串??

相关代码如下:

服务器.rb

 get '/:developer' do
  @workflow_audits = Auditor.new(params['developer']).workflow_audits
  haml :dashboard, :layout => :layout
 end

View /layout.haml

%html
  %head
    %title Workflow Stuff
    %link{ :rel => :stylesheet, :type => "text/scss", :href => "/stylesheets/dashboard.scss"}
    %script{ :src => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js" }

  %body
    %form{action: '/', method: 'post'}
      %label{for: 'developer'}Select a developer:
      %input{type: 'text', name: 'developer'}
      %input{type: 'submit', value: 'submit'}

    = yield

View /dashboard.haml

%ul.issue-list
   - @workflow_audits.each do |audit|
      %li.issue
        .issue-container.row

最佳答案

dashboard.haml 中存在缩进问题。我删除了您帖子中的 3 个空格和制表符,并在各处放置了两个空格,所有错误都消失了并且能够正常工作。

%ul.issue-list
  - @workflow_audits.each do |audit|
    %li.issue
      .issue-container.row

关于html - 使用 Sinatra 布局生成模板 : Yields stringified version of my html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27114983/

相关文章:

C++ 模板 ByRef 与 ByVal

ruby-on-rails - 如何修复 Ruby 2.0.0p645 的段错误

ruby - Sidekiq 网页面板显示禁止

html - 仅CSS的砌体布局

python - 为什么我在 Django 中的模板标签不起作用?

c++ - 继承和模板参数

ruby sinatra,postgres分页结果

javascript - 如何在父级之上显示 iframe 弹出窗口?

html - 在 css 转换下消除 ul 高度的波动

javascript - Electron 标签意外地将所有标签源加载到同一个标签中