Sha256: 7bfe40b76c47b7b465bf84d1a06a94a94fe2ec42741559619375cb72dabd6b74

Contents?: true

Size: 888 Bytes

Versions: 28

Compression:

Stored size: 888 Bytes

Contents

module ExpressTemplates
  module Components
    class Container < Configurable

      class_attribute :prepended_blocks
      self.prepended_blocks = []

      class_attribute :appended_blocks
      self.appended_blocks = []

      contains -> (&block) {
        prepended
        block.call(self) if block
        appended
      }

      def prepended
        prepended_blocks.each do |block_to_prepend|
          call_block(block_to_prepend)
        end
      end

      def appended
        appended_blocks.each do |block_to_append|
          call_block(block_to_append)
        end
      end

      def call_block(block)
        instance_exec &block
      end

      def self.prepends(proc = nil, &block)
        self.prepended_blocks += [proc || block]
      end

      def self.appends(proc = nil, &block)
        self.appended_blocks += [proc || block]
      end

    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
express_admin-1.6.4 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.11.2 lib/express_templates/components/container.rb
express_admin-1.6.3 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.11.1 lib/express_templates/components/container.rb
express_admin-1.6.2 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_admin-1.6.1 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.11.0 lib/express_templates/components/container.rb
express_admin-1.6.0 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.10.1 lib/express_templates/components/container.rb
express_admin-1.5.0 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_admin-1.4.11 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_admin-1.4.10 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_admin-1.4.9 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.9.8 lib/express_templates/components/container.rb
express_admin-1.4.8 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.9.7 lib/express_templates/components/container.rb
express_admin-1.4.7 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.9.6 lib/express_templates/components/container.rb
express_admin-1.4.6 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.9.5 lib/express_templates/components/container.rb