Sha256: 9a8bb75949b7e0cb1ce107f9042c73d0ea81915efb383b0de824d8ea925ef9cd

Contents?: true

Size: 818 Bytes

Versions: 3

Compression:

Stored size: 818 Bytes

Contents

require_relative "base_renderer.rb"
require_relative "common_features/helperable.rb"
require_relative "common_features/capturable.rb"

module Docks
  module Renderers
    class Slim < Base
      include Common::Helperable
      include Common::Capturable

      def initialize
        require "slim"
        super
      end

      def render(template, locals = {})
        content, layout, locals = normalize_content_and_locals(template, locals)
        return if content.nil?

        content = ::Slim::Template.new { content }.render(self, locals)
        return content if layout.nil?

        ::Slim::Template.new { layout }.render(self, locals) do |name|
          name.nil? ? content : @content_blocks[name]
        end
      end

      def capture(*args, &block)
        yield *args
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docks_app-0.0.3 lib/docks/renderers/slim_renderer.rb
docks_app-0.0.2 lib/docks/renderers/slim_renderer.rb
docks_app-0.0.1 lib/docks/renderers/slim_renderer.rb