Module: TaoOnRails::ActionView::Helpers
- Defined in:
- lib/tao_on_rails/action_view/helpers.rb
Class Method Summary collapse
-
.define_component_helpers ⇒ Object
Define the dynamic view helpers for components This method should be called in action_view context.
- .load_tao_components(root = Rails.root) ⇒ Object
Instance Method Summary collapse
Class Method Details
.define_component_helpers ⇒ Object
Define the dynamic view helpers for components This method should be called in action_view context
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tao_on_rails/action_view/helpers.rb', line 13 def self.define_component_helpers load_tao_components ::ActiveSupport.run_load_hooks(:tao_components, self) TaoOnRails::Components::Base.descendants.each do |klass| module_eval %Q{ def #{klass.tag_name.underscore} *args, &block #{klass.name}.new(self, *args).render(&block) end } end end |
.load_tao_components(root = Rails.root) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/tao_on_rails/action_view/helpers.rb', line 26 def self.load_tao_components(root = Rails.root) Dir.glob([ root.join('lib/components/**/*.rb'), root.join('app/components/**/*.rb') ]).each do |component| require_dependency component end end |
Instance Method Details
#page_id ⇒ Object
5 6 7 8 9 |
# File 'lib/tao_on_rails/action_view/helpers.rb', line 5 def page_id return @page_id if defined?(@page_id) controller_names = controller_path.split('/') [controller_names, action_name].compact.flatten.join('_').dasherize end |