Sha256: d29e8039f03865bdf971d538fe5bae3b490a3d8f7473435e3a9b576e7f14c9f8

Contents?: true

Size: 709 Bytes

Versions: 1

Compression:

Stored size: 709 Bytes

Contents

# frozen_string_literal: true

module Ki
  module Middleware
    module Helpers
      module HamlCompiler
        def render_haml_file(file_path, layout = true)
          file_contents = File.read(file_path)

          layout_contents = if layout && view_exists?('layout')
                              File.read(view_path('layout'))
                            else
                              '= yield'
                            end

          html = render_haml(layout_contents).render do
            render_haml(file_contents).render
          end

          html
        end

        def render_haml(s)
          Haml::Engine.new("- extend Ki::Helpers\n" + s)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ki-0.4.12 lib/ki/middleware/helpers/haml_compiler_helper.rb