Sha256: 32aa34da0cdbc8530d633883bfbff4a26cd380ca5c04bad2b526b66007fa3710

Contents?: true

Size: 847 Bytes

Versions: 14

Compression:

Stored size: 847 Bytes

Contents

# Copyright 2011-2013 Rice University. Licensed under the Affero General Public 
# License version 3 or later.  See the COPYRIGHT file for details.
   
require 'attribeautiful'

module OpenStax::Utilities::Blocks 
  class BlockBase
    include Attribeautiful

    attr_accessor :captured_block

    def initialize(template, partial, passed_block)
      self.h            = template
      self.passed_block = passed_block
      self.partial      = partial
    end

    def to_s
      render_passed_block
      render_partial
    end

  protected

    attr_accessor :h
    attr_accessor :passed_block
    attr_accessor :partial

    def render_passed_block
      self.captured_block ||= h.capture self, &passed_block
    end

    def render_partial
      h.render :partial => "osu/shared/#{partial}", :locals => { :block => self }
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
openstax_utilities-2.2.3 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-2.2.2 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-2.2.1 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-2.2.0 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-2.1.0 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-2.0.0 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-1.3.0 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-1.2.0 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-1.1.0 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-1.0.2 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-1.0.1 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-1.0.0 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-0.0.7 lib/openstax/utilities/blocks/block_base.rb
openstax_utilities-0.0.6 lib/openstax/utilities/blocks/block_base.rb