Module: ExpressTemplates::Components::Capabilities::Configurable

Included in:
ExpressTemplates::Components::Column, ExpressTemplates::Components::ContentFor, FormRailsSupport, Row, TableFor
Defined in:
lib/express_templates/components/capabilities/configurable.rb

Overview

Configurable components accept options which they can use to alter their markup each time they are invoked within a template.

They do not compile their markup fragments at load time as simpler components do for efficiency. Rather they compile their fragments when they are themselves undergoing compilation. This facilitates access to arguments which were passed to the component at initialization.

For example, if we have a Row component that is Configurable:

row(:main)

might process to:

<div id="main" class="row" />

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/express_templates/components/capabilities/configurable.rb', line 23

def self.included(base)
  base.class_eval do
    extend ClassMethods
    include InstanceMethods

    # Stores arguments for later processing, eg., compile time
    def initialize(*args)
      @args = args.dup
      _process_args!(args)
      super(*args)
    end
  end
end