class Bytewise::Helpers::Helper

Constants

HELPERS

Public Class Methods

get_klass(name) click to toggle source

Applies a filter with a given name and passes the arguments to apply

# File lib/brace_markup/helpers/helper.rb, line 66
def self.get_klass(name)
  name = name.to_sym if name.is_a? String

  if HELPERS.key? name
    Object.const_get(HELPERS[name])
  else
    raise Exception.new("Helper '#{name}' not found.")
  end
end
map(name) click to toggle source

Maps a helper with a name Usage:

class MathModHelper < ::Bytewise::Helpers::Helper

map :'math.mod'

def render(a:, b:)
   a % b
end

end

# File lib/brace_markup/helpers/helper.rb, line 58
def self.map(name)
  name = name.to_sym if name.is_a? String
  HELPERS[name] = self.name
end
new(tag:, context:, ** args) click to toggle source
# File lib/brace_markup/helpers/helper.rb, line 5
def initialize(tag:, context:, ** args)
  @tag = tag
  @context = context
end

Public Instance Methods

get_sections(name) click to toggle source
# File lib/brace_markup/helpers/helper.rb, line 34
def get_sections(name)
  result = []

  @tag.sections.each do |s|
    if s.name == name
      result << s
    end
  end

  result
end
render(** args) click to toggle source

The return value of this method will be written to the chunk

# File lib/brace_markup/helpers/helper.rb, line 14
def render(** args)

end
render_children() click to toggle source
# File lib/brace_markup/helpers/helper.rb, line 18
def render_children
  if @tag.body.children?
    @tag.body.render @context
  end
end
render_section(name) click to toggle source
# File lib/brace_markup/helpers/helper.rb, line 24
def render_section(name)
  @tag.sections.each do |s|
    if s.name == name
      return s.render(@context)
    end
  end

  ''
end