Module: StaticMatic::HelpersMixin

Included in:
Base
Defined in:
lib/staticmatic/mixins/helpers.rb

Instance Method Summary collapse

Instance Method Details

#load_helper(helper) ⇒ Object



10
11
12
13
14
# File 'lib/staticmatic/mixins/helpers.rb', line 10

def load_helper(helper)
  load helper
  module_name = File.basename(helper, '.rb').gsub(/(^|\_)./) { |c| c.upcase }.gsub(/\_/, '')
  Haml::Helpers.class_eval("include #{module_name}")
end

#load_helpersObject

Loads any helpers present in the helpers dir and mixes them into the template helpers



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

def load_helpers

  Dir["#{@src_dir}/helpers/**/*_helper.rb"].each do |helper|
    load_helper(helper)
  end
end