Sha256: 4ed3661f7c76d51c2e80cb27e767712b9dd381a8ac05252940bc75de04678deb

Contents?: true

Size: 869 Bytes

Versions: 2

Compression:

Stored size: 869 Bytes

Contents

class Shortcode::TemplateBinding

  def initialize(name, configuration, attributes=[], content='', additional_attributes=nil)
    @configuration = configuration
    include_helper_modules
    presenter      = Shortcode::Presenter.new name, configuration, set_attributes(attributes), content, additional_attributes
    @name          = name
    @attributes    = presenter.attributes
    @content       = presenter.content
  end

  # Expose private binding() method for use with erb templates
  def get_binding
    binding
  end

  private

  attr_reader :configuration

  def set_attributes(attributes)
    hash = {}
    attributes.each { |o| hash[o[:key].to_sym] = o[:value] }
    hash
  end

  def include_helper_modules
    return unless configuration.helpers.any?

    configuration.helpers.each do |helper|
      self.class.send(:include, helper)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shortcode-1.2.1 lib/shortcode/template_binding.rb
shortcode-1.2.0 lib/shortcode/template_binding.rb