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.4.5 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.9.4 lib/express_templates/components/container.rb
express_templates-0.9.3 lib/express_templates/components/container.rb
express_admin-1.4.4 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_admin-1.4.3 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.9.1 lib/express_templates/components/container.rb
express_admin-1.4.2 vendor/gems/express_templates/lib/express_templates/components/container.rb
express_templates-0.9.0 lib/express_templates/components/container.rb