Sha256: c91402a24fbdd658f2580719abbab56592c09f1f60d0f8ca3630e4020970b32b

Contents?: true

Size: 892 Bytes

Versions: 3

Compression:

Stored size: 892 Bytes

Contents

module TaoOnRails
  module ActionView
    module Helpers

      def page_id
        return @page_id if @page_id.present?
        controller_names = controller_path.split('/')
        [controller_names, action_name].compact.flatten.join('_').dasherize
      end

      # Define the dynamic view helpers for components
      # This method should be called in action_view context
      def self.define_component_helpers
        Dir.glob([
          Rails.root.join('lib/components/**/*.rb'),
          Rails.root.join('app/components/**/*.rb')
        ]).each do |component|
          require component
        end

        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

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tao_on_rails-0.8.2 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.8.1 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.8.0 lib/tao_on_rails/action_view/helpers.rb