Changeset 1037
- Timestamp:
- 11/23/07 02:32:45 (1 year ago)
- Files:
-
- plugins/merb_helpers/README (modified) (1 diff)
- plugins/merb_helpers/lib/merb_helpers.rb (modified) (1 diff)
- plugins/merb_helpers/lib/merb_helpers/date_time_helpers.rb (added)
- plugins/merb_helpers/lib/merb_helpers/form_helpers.rb (moved) (moved from plugins/merb_helpers/lib/form_helpers.rb)
- plugins/merb_helpers/lib/merb_helpers/form_model.rb (moved) (moved from plugins/merb_helpers/lib/form_model.rb)
- plugins/merb_helpers/lib/merb_helpers/merbtasks.rb (deleted)
- plugins/merb_helpers/lib/tasks (added)
- plugins/merb_helpers/lib/tasks/merb_tasks.rb (added)
- plugins/merb_helpers/specs/fixtures (added)
- plugins/merb_helpers/specs/fixtures/plugins_with.yml (added)
- plugins/merb_helpers/specs/fixtures/plugins_without.yml (added)
- plugins/merb_helpers/specs/merb_helpers_config_spec.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/merb_helpers/README
r710 r1037 2 2 ================= 3 3 4 A plugin for the Merb framework that provides .... 4 A plugin for the Merb Web framework that provides different view helpers. 5 6 To use this plugin in merb in your app 7 8 config/dependencies.rb 9 10 #... 11 12 dependency "merb_helpers" 13 14 #... 15 16 By default all modules of merb_helpers are loaded and are available to your merb app. 17 18 You can selectively include/exclude modules from this list to keep you app lean if you like. 19 The inclusions/exclusions are relative to all modules. 20 21 :include: will only include the specified modules. 22 23 :exclude: will include all except the specified modules. 24 25 Do not use :include: and :exclude: options at the same time or an error will be raised. 26 27 To set this up in config/plugins.yml 28 29 To Include specified helpers 30 31 :merb_helpers: 32 :include: - date_time_helpers 33 - form_helpers 34 35 36 To Exclude specified helpers 37 38 :merb_helpers: 39 :exclude: - date_time_helpers 40 - form_helpers plugins/merb_helpers/lib/merb_helpers.rb
r710 r1037 1 # make sure we're running inside Merb 2 if defined?(Merb::Plugins) 1 module Merb 2 3 module Helpers 4 HELPERS_DIR = File.join(File.dirname(__FILE__), 'merb_helpers') 5 HELPERS_FILES = Dir["#{HELPERS_DIR}/*_helpers.rb"].collect {|h| h.match(/\/(\w+)\.rb/)[1]} 6 7 def self.load_helpers(helpers = HELPERS_FILES) 8 helpers.each {|h| Kernel.load(File.join(HELPERS_DIR, "#{h}.rb") )} # using load here allows specs to work 9 end 10 11 def self.load 12 if Merb::Plugins.config[:merb_helpers] 13 config = Merb::Plugins.config[:merb_helpers] 14 raise "With and Without options cannot be used with merb_helpers plugin configuration" if config[:with] && config[:without] 15 if config[:include] 16 load_helpers(config[:include]) 17 elsif config[:exclude] 18 load_helpers(HELPERS_FILES.reject {|h| config[:exclude].include? h}) 19 else 20 # This is in case someone defines an entry in the config, 21 # but doesn't put in a with or without option 22 load_helpers 23 end 24 else 25 load_helpers 26 end 3 27 4 # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it5 Merb::Plugins.config[:merb_helpers] = {6 :chickens => false7 }28 Merb::Plugins.add_rakefiles "tasks/merb_tasks" 29 end 30 31 end 8 32 9 require 'form_model'10 require 'form_helpers'11 Merb::Plugins.add_rakefiles "merb_helpers/merbtasks"12 33 end 34 35 Merb::Helpers.load if defined?(Merb::Plugins)
