Module: Merb::Helpers

Defined in:
merb-helpers/lib/merb-helpers.rb,
merb-helpers/lib/merb-helpers/version.rb,
merb-helpers/lib/merb-helpers/tag_helpers.rb,
merb-helpers/lib/merb-helpers/date_time_helpers.rb

Defined Under Namespace

Modules: DateAndTime, Form, Tag, Text

Constant Summary

VERSION =
'1.2.0'.freeze
@@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

+ (Object) load



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

def self.load

  require 'merb-helpers/time_dsl'
  require 'merb-helpers/core_ext'
  require 'merb-helpers/core_ext/numeric'

  if Merb::Plugins.config[:merb_helpers]
    config = Merb::Plugins.config[:merb_helpers]

    if config[:include] && !config[:include].empty?
      load_helpers(config[:include])
    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
end

+ (Object) load_helpers(helpers = @@helpers_files)

Load only specific helpers instead of loading all the helpers



33
34
35
36
# File 'merb-helpers/lib/merb-helpers.rb', line 33

def self.load_helpers(helpers = @@helpers_files)
  helpers = helpers.is_a?(Array) ? helpers : [helpers]
  helpers.each {|helper| Kernel.load(File.join(@@helpers_dir, "#{helper}.rb") )} # using load here allows specs to work
end