class Shortcode::TemplateBinding

Attributes

configuration[R]

Public Class Methods

new(name, configuration, attributes=[], content="", additional_attributes=nil) click to toggle source
# File lib/shortcode/template_binding.rb, line 3
def initialize(name, configuration, attributes=[], content="", additional_attributes=nil)
  @configuration = configuration
  include_helper_modules
  presenter = Shortcode::Presenter.new name,
                                       configuration,
                                       map_attributes(attributes),
                                       content,
                                       additional_attributes
  @name = name
  @attributes = presenter.attributes
  @content = presenter.content
end

Public Instance Methods

expose_binding() click to toggle source

Expose private binding() method for use with erb templates

# File lib/shortcode/template_binding.rb, line 17
def expose_binding
  binding
end

Private Instance Methods

include_helper_modules() click to toggle source
# File lib/shortcode/template_binding.rb, line 31
def include_helper_modules
  return unless configuration.helpers.any?

  configuration.helpers.each do |helper|
    self.class.send(:include, helper)
  end
end
map_attributes(attributes) click to toggle source
# File lib/shortcode/template_binding.rb, line 25
def map_attributes(attributes)
  hash = {}
  attributes.each { |o| hash[o[:key].to_sym] = o[:value] }
  hash
end