Module: Merb::Helpers

Defined in:
lib/merb_helpers/form_helpers.rb,
lib/merb_helpers.rb,
lib/merb_helpers/date_time_helpers.rb

Overview

Merb helpers include several helpers used for simplifying view creation. The available helpers currently include form tag helpers for both resource based and generic HTML form tag creation

Defined Under Namespace

Modules: DateAndTime, Form

Constant Summary collapse

HELPERS_DIR =
File.dirname(__FILE__) / 'merb_helpers'
HELPERS_FILES =
Dir["#{HELPERS_DIR}/*_helpers.rb"].collect {|h| h.match(/\/(\w+)\.rb/)[1]}

Class Method Summary collapse

Class Method Details

.loadObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/merb_helpers.rb', line 11

def self.load
  if Merb::Plugins.config[:merb_helpers]
    config = Merb::Plugins.config[:merb_helpers]
    raise "With and Without options cannot be used with merb_helpers plugin configuration" if config[:with] && config[:without]
    if config[:include]
      load_helpers(config[:include])
    elsif config[:exclude]
      load_helpers(HELPERS_FILES.reject {|h| config[:exclude].include? h})
    else
      # This is in case someone defines an entry in the config,
      # but doesn't put in a with or without option
      load_helpers
    end
  else
    load_helpers
  end

  Merb::Plugins.add_rakefiles "tasks/merb_tasks"
end

.load_helpers(helpers = HELPERS_FILES) ⇒ Object



7
8
9
# File 'lib/merb_helpers.rb', line 7

def self.load_helpers(helpers = HELPERS_FILES)
  helpers.each {|h| Kernel.load(File.join(HELPERS_DIR, "#{h}.rb") )} # using load here allows specs to work
end