Unable to use HAML layouts with Middleman

I'm having trouble switching from the default file to layout.erbthe equivalent file layout.hamlin Middleman. I want to use HAML for my layouts, as I try to familiarize myself with it, so I decided to replace the default layout with the HAML version. Unfortunately, when I replace layout.erbwith layout.haml, I get this error:

NoMethodError at /
undefined method `force_encoding' for nil:NilClass

Ruby    /Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in ensure in binary, line 289
Web GET localhost/

Traceback (innermost first)

/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in ensure in binary
      string.force_encoding(original_encoding)...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in binary
      string.force_encoding(original_encoding)...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in extract_magic_comment
      binary script do...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in extract_encoding
      extract_magic_comment(script) || script.encoding...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in precompiled
        template_encoding = extract_encoding(template)...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/erb.rb: in precompiled
        source, offset = super...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/erb.rb: in precompiled
        source, offset = super...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in compile_template_method
      source, offset = precompiled(locals)...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in compiled_method
        compile_template_method(locals_keys)...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in evaluate
      method = compiled_method(locals.keys)...
/Library/Ruby/Gems/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb: in render
      evaluate scope, locals || {}, &block...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/core_extensions/rendering.rb: in render_individual_file
          content = template.render(context, locs, &block)...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/core_extensions/rendering.rb: in render_template
            content = render_individual_file(layout_path, locs, opts, context) { content }...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/sitemap/resource.rb: in block in render
          app.render_template(source_file, locs, opts, blocks)...
/Library/Ruby/Gems/2.0.0/gems/activesupport-4.1.4/lib/active_support/notifications.rb: in instrument
          yield payload if block_given?...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/util.rb: in instrument
        ::ActiveSupport::Notifications.instrument(suffixed_name, payload, &block)...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/application.rb: in instrument
    delegate :instrument, to: ::Middleman::Util...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/sitemap/resource.rb: in instrument
      delegate :logger, :instrument, to: :app...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/sitemap/resource.rb: in render
        instrument 'render.resource', path: relative_source, destination_path: destination_path  do...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/core_extensions/request.rb: in process_request
            output = resource.render do...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/core_extensions/request.rb: in block in call!
            process_request(env, req, res)...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/core_extensions/request.rb: in catch
          catch(:halt) do...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/core_extensions/request.rb: in call!
          catch(:halt) do...
/Library/Ruby/Gems/2.0.0/gems/middleman-core-3.3.3/lib/middleman-core/core_extensions/request.rb: in call
          dup.call!(env)...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb: in call
      to_app.call(env)...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb: in block in call
        return app.call(env)...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb: in each
      @mapping.each do |host, location, match, app|...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/urlmap.rb: in call
      @mapping.each do |host, location, match, app|...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/showexceptions.rb: in call
      @app.call(env)...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/head.rb: in call
    status, headers, body = @app.call(env)...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb: in _call
      status, headers, @body = @app.call(env)...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb: in call
      dup._call(env)...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb: in call
      to_app.call(env)...
/Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb: in service
        status, headers, body = @app.call(env)...
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb: in service
      si.service(req, res)...
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/httpserver.rb: in run
          server.service(req, res)...
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/webrick/server.rb: in block in start_thread
          block ? block.call(sock) : run(sock)

layout.erb as follows:

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">

    <!-- Always force latest IE rendering engine or request Chrome Frame -->
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">

    <!-- Use title if it in the page YAML frontmatter -->
    <title><%= current_page.data.title || "The Middleman" %></title>

    <%= stylesheet_link_tag "normalize" %>
    <!-- <%= stylesheet_link_tag "normalize", "all" %> -->
    <%= javascript_include_tag  "all" %>
  </head>

  <body class="<%= page_classes %>">
    <%= partial "header" %>
    <%= yield %>
    <%= partial "footer" %>
  </body>
</html>

layout.hamldoesn't have the same content as layout.erb, but it doesn’t seem to matter as it breaks regardless of what:

!!!
%html
  %head
    %title
      = current_page.data.title || "The Middleman"
    = stylesheet_link_tag "normalize", "all"
    = javascript_include_tag "all"
  %body
    = partial "header"
    = yield
    = partial "footer"

, , HAML , HAML, doctype, html, head, title body, . , ERb, , layout.haml layout.erb, , HAML. layout.erb sublayout article_layout.haml , article_layout.erb .

, , Middleman ERb . , , layout.haml . ? , middleman init, HAML ? ?

+4
1

@r.pazyaquian, , .

+3

All Articles