Module: Microframe::Helpers
- Included in:
- ApplicationController, ViewObject
- Defined in:
- lib/microframe/controller/helpers.rb
Instance Method Summary collapse
- #form_for(target, link = nil) {|FormHelper.new(target, link)| ... } ⇒ Object
- #image_tag(image, ext = "png") ⇒ Object
- #javascript_tag(js) ⇒ Object
- #link_to(link, target, options = {}) ⇒ Object
- #stylesheet_tag(style, ext = "css") ⇒ Object
Instance Method Details
#form_for(target, link = nil) {|FormHelper.new(target, link)| ... } ⇒ Object
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 |
#link_to(link, target, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/microframe/controller/helpers.rb', line 5 def link_to(link, target, = {}) if [: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='#{[:method]}'/><input type='submit' value='#{link}' /></form>" else = "" [:data].each { |key, val| << "data-#{key}='#{val}'"} if [:data] "<a href='#{target}' #{} >#{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 |