Sha256: 337600ebb7213579fce5a7742005c4ca65113a160d3b5f1ed3486d65e65289ce

Contents?: true

Size: 704 Bytes

Versions: 6

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

module ::AmberComponent
  # Provides code which handles rendering different
  # template languages.
  module TemplateHandler
    class << self
      # @param context [AmberComponent::Base]
      # @param content [String]
      # @param type [Symbol, String]
      # @param block [Proc, nil]
      # @return [String]
      def render_from_string(context, content, type, block = nil)
        options = if type.to_sym == :erb
                    { engine_class: ERB }
                  else
                    {}
                  end

        ::Tilt[type].new(options) { content }.render(context, &block)
      end
    end
  end
end

require_relative 'template_handler/erb'

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
amber_component-1.1.1 lib/amber_component/template_handler.rb
amber_component-1.1.0 lib/amber_component/template_handler.rb
amber_component-1.0.0 lib/amber_component/template_handler.rb
amber_component-0.0.5 lib/amber_component/template_handler.rb
amber_component-0.0.4 lib/amber_component/template_handler.rb
amber_component-0.0.3 lib/amber_component/template_handler.rb