emag3m
emag3m

Reputation: 95

Yielding Templates through Layout with Sinatra: Yields stringified version of my html

Within a sinatra framework, I'm trying to yield a template, dashboard.haml, within a layout template: layout.haml. But when the page loads, a stringified version of the html appears, instead of the HTML itself. So it's clearly fetching the correct template, but I wonder why the html is being rendered as a string??

Here are the relevant code:

server.rb

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

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

views/dashboard.haml

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

Upvotes: 2

Views: 482

Answers (1)

Phobos
Phobos

Reputation: 737

You have an indentation issue in dashboard.haml. I removed the 3 spaces and tabs in your post and put two spaces everywhere, all errors went away and was able to get it working.

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

Upvotes: 2

Related Questions