Sha256: fe804f95f8241d7f0104e8f23c3f009bfe7c5198e97bff1404c44afce6a2e35a

Contents?: true

Size: 893 Bytes

Versions: 2

Compression:

Stored size: 893 Bytes

Contents

module TaoOnRails
  module ActionView
    module Helpers

      def page_id
        return @page_id if defined?(@page_id)
        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

2 entries across 2 versions & 1 rubygems

Version Path
tao_on_rails-0.9.1 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.9.0 lib/tao_on_rails/action_view/helpers.rb