module Hamloft::Helpers

Public Instance Methods

asset(url) click to toggle source

styles

# File lib/hamloft/helpers.rb, line 13
def asset(url)
  "#{asset_uri}/themes/#{@_haml_locals[:theme]}/#{url}"
end
asset_uri() click to toggle source
# File lib/hamloft/helpers.rb, line 21
def asset_uri
  @_haml_locals[:asset_uri] || Hamloft.asset_uri
end
block(identifier, variables = {}) click to toggle source
# File lib/hamloft/helpers.rb, line 7
def block(identifier, variables = {})
  haml_contents = Hamloft.block_resolver.resolve(identifier, @_haml_locals)
  Hamloft.render(haml_contents, @_haml_locals.merge(variables))
end
drop_container() click to toggle source

drop container

# File lib/hamloft/helpers.rb, line 74
def drop_container
  haml_tag :div, class: '_typeloft_widget_drop_container'
end
font(font_face) { || ... } click to toggle source
# File lib/hamloft/helpers.rb, line 53
def font(font_face, &block)
  haml_tag :font, face: font_face do
    yield if block
  end
end
parse_html(key, type) click to toggle source
# File lib/hamloft/helpers.rb, line 33
def parse_html(key, type)
  if (html = @_haml_locals[key.to_sym]) && !Hamloft.template(type).nil?
    template = Hamloft.template(type).new(self, html)
    template.container do
      template.chunks.each do |chunk|
        template.process_chunk(chunk)
      end
    end
  end
end
root_asset(url) click to toggle source
# File lib/hamloft/helpers.rb, line 17
def root_asset(url)
  "#{asset_uri}/#{url}"
end
style(*args) { || ... } click to toggle source
# File lib/hamloft/helpers.rb, line 59
def style(*args, &block)
  style = nil
  if args[-1].class.name == 'Hash'
    style_options = args.pop
    style = style_string(style_options, *style_options.keys)
  end

  classes = args.map { |a| "__#{a}" }
  haml_tag :span, class: classes.join(' '), style: style do
    yield if block
  end
end
style_string(options, *args, &block) click to toggle source
# File lib/hamloft/helpers.rb, line 3
def style_string(options, *args, &block)
  Hamloft::StyleBuilder.new(options, args).process(block)
end
var(key, default = nil) click to toggle source
# File lib/hamloft/helpers.rb, line 25
def var(key, default = nil)
  variable(:variables, {})[key.to_sym] || default
end
variable(key, default = false) click to toggle source
# File lib/hamloft/helpers.rb, line 29
def variable(key, default = false)
  @_haml_locals[key.to_sym] || default
end
widget(identifier, options={}, &block) click to toggle source
# File lib/hamloft/helpers.rb, line 78
def widget(identifier, options={}, &block)
  widget = Hamloft.widgets[identifier].new(options, self)
  haml_tag "#{identifier}-widget", widget.widget_options do
    widget.template(&block)
  end
end