module TaoOnRails::ActionView::Helpers

Public Instance Methods

define_component_helpers() click to toggle source

Define the dynamic view helpers for components This method should be called in action_view context

# File lib/tao_on_rails/action_view/helpers.rb, line 15
def 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) click to toggle source
# File lib/tao_on_rails/action_view/helpers.rb, line 28
def 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
page_id() click to toggle source
# File lib/tao_on_rails/action_view/helpers.rb, line 6
def page_id
  return @page_id if defined?(@page_id)
  controller_names = controller_path.split('/')
  [controller_names, action_name].compact.flatten.join('_').dasherize
end