Module: Microframe::Helpers

Included in:
ApplicationController, ViewObject
Defined in:
lib/microframe/controller/helpers.rb

Instance Method Summary collapse

Instance Method Details

#form_for(target, link = nil) {|FormHelper.new(target, link)| ... } ⇒ Object

Yields:



17
18
19
# File 'lib/microframe/controller/helpers.rb', line 17

def form_for(target, link=nil, &block)
  yield(FormHelper.new(target, link))
end

#image_tag(image, ext = "png") ⇒ Object



21
22
23
# File 'lib/microframe/controller/helpers.rb', line 21

def image_tag(image, ext = "png")
  File.join(APP_PATH, "app", "assets", "images", "#{image}.#{ext}")
end

#javascript_tag(js) ⇒ Object



25
26
27
# File 'lib/microframe/controller/helpers.rb', line 25

def javascript_tag(js)
  File.join(APP_PATH, "app", "assets", "javascripts", "#{js}.js")
end


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/microframe/controller/helpers.rb', line 5

def link_to(link, target, options = {})
  if options[:method]
    target = target.is_a?(String) ? target : "/#{target.class.to_s.downcase}s/#{target.id}"

    "<form action='#{target}' method='post'><input type='hidden' name='_method' value='#{options[:method]}'/><input type='submit' value='#{link}' /></form>"
  else
    data_options = ""
    options[:data].each { |key, val| data_options << "data-#{key}='#{val}'"} if options[:data]
    "<a href='#{target}' #{data_options} >#{link}</a>"
  end
end

#stylesheet_tag(style, ext = "css") ⇒ Object



29
30
31
# File 'lib/microframe/controller/helpers.rb', line 29

def stylesheet_tag(style, ext = "css")
  File.join(APP_PATH, "app", "assets", "stylesheets", "#{style}.#{ext}")
end