Module: Hamloft::Helpers

Included in:
Widget
Defined in:
lib/hamloft/helpers.rb

Instance Method Summary collapse

Instance Method Details

#asset(url) ⇒ Object

styles



9
10
11
# File 'lib/hamloft/helpers.rb', line 9

def asset(url)
  "#{Hamloft::Options.defaults[:asset_uri]}/themes/#{@_haml_locals[:theme]}/#{url}"
end

#drop_containerObject

drop container



58
59
60
# File 'lib/hamloft/helpers.rb', line 58

def drop_container
  haml_tag :div, :class => "_typeloft_widget_drop_container"
end

#font(font_face, &block) ⇒ Object



37
38
39
40
41
# File 'lib/hamloft/helpers.rb', line 37

def font(font_face, &block)
  haml_tag :font, :face => font_face do
    block.call if block
  end
end


28
29
30
31
32
33
34
35
# File 'lib/hamloft/helpers.rb', line 28

def link(href, referrer="Baker", &block)
  if referrer and not referrer.empty? and not href.include?("referrer=")
    href = "#{href}#{href.include?("?") ? "&" : "?"}referrer=#{referrer}"
  end
  haml_tag :a, :href => href do
    block.call if block
  end
end

#parse_html(key, type) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/hamloft/helpers.rb', line 17

def parse_html(key, type)
  if html = @_haml_locals[key.to_sym] and not 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

#style(*args, &block) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/hamloft/helpers.rb', line 43

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
    block.call if block
  end    
end

#style_string(options, *args, &block) ⇒ Object



4
5
6
# File 'lib/hamloft/helpers.rb', line 4

def style_string(options, *args, &block)
  Hamloft::StyleBuilder.new(options, args).process(block)
end

#variable(key, default = false) ⇒ Object



13
14
15
# File 'lib/hamloft/helpers.rb', line 13

def variable(key, default=false)
  @_haml_locals[key.to_sym] || default
end

#widget_block(widget, &block) ⇒ Object

widgets



64
65
66
67
68
# File 'lib/hamloft/helpers.rb', line 64

def widget_block(widget, &block)
  haml_tag :div, widget.typeloft_widget_options do
    block.call(widget) if block
  end
end