Module: Antwort::MarkupHelpers

Defined in:
lib/antwort/helpers/markup_helper.rb

Instance Method Summary collapse

Instance Method Details

#button(text, url, opts = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/antwort/helpers/markup_helper.rb', line 10

def button(text, url, opts = {})
  locals = {
    text: text,
    url: url
  }.merge(opts)
  render_markup('button', locals)
end

#counter_classes(index) ⇒ Object



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

def counter_classes(index)
  # 0 index based
  klass = ''
  klass += index.even? ? ' is-2n' : ''
  klass += (index % 3).zero? ? ' is-3n' : ''
  klass += (index % 4).zero? ? ' is-4n' : ''
  klass += (index % 6).zero? ? ' is-6n' : ''
  klass
end

#image_tag(path, opts = {}) ⇒ Object



3
4
5
6
7
8
# File 'lib/antwort/helpers/markup_helper.rb', line 3

def image_tag(path, opts = {})
  locals = {
    source: image_url_from_path(path)
  }.merge!(opts)
  render_markup('image_tag', locals).delete("\n")
end

#markup_viewsObject



18
19
20
# File 'lib/antwort/helpers/markup_helper.rb', line 18

def markup_views
  File.expand_path('../server/views/markup', File.dirname(__FILE__))
end

#render_markup(template, locals) ⇒ Object



22
23
24
25
# File 'lib/antwort/helpers/markup_helper.rb', line 22

def render_markup(template, locals)
  scope = OpenStruct.new
  Tilt::ERBTemplate.new("#{markup_views}/#{template}.html.erb").render(scope, locals)
end