在 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/