Sha256: 3c870a5d2bda5bd6563240bba5d88b0ab67b390b9358e2939ec0eb5ac56fb098

Contents?: true

Size: 798 Bytes

Versions: 27

Compression:

Stored size: 798 Bytes

Contents

module MasterView
  module Directives

    #outputs a block around the text tags, if left bracket count is higher than right
    #assume that the end is a right bracket otherwise use end
    class Block < MasterView::DirectiveBase
      def priority
        DirectivePriorities::MediumHigh
      end

      def stag(directive_call_stack)
        count_left_brackets = attr_value.scan( /\{/ ).size
        count_right_brackets = attr_value.scan( /\}/ ).size
        @end_block = (count_left_brackets > count_right_brackets) ? '}' : 'end'

        ret = []
        ret << erb(attr_value)
        ret << directive_call_stack.render
      end

      def etag(directive_call_stack)
        ret = []
        ret << directive_call_stack.render
        ret << erb(@end_block)
      end

    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
masterview-0.0.13 lib/masterview/directives/block.rb
masterview-0.0.14 lib/masterview/directives/block.rb
masterview-0.0.15 lib/masterview/directives/block.rb
masterview-0.0.16 lib/masterview/directives/block.rb
masterview-0.0.17 lib/masterview/directives/block.rb
masterview-0.0.2 lib/masterview/directives/block.rb
masterview-0.0.10 lib/masterview/directives/block.rb
masterview-0.0.11 lib/masterview/directives/block.rb
masterview-0.0.12 lib/masterview/directives/block.rb
masterview-0.1.1 lib/masterview/directives/block.rb
masterview-0.1.0 lib/masterview/directives/block.rb
masterview-0.2.1 lib/masterview/directives/block.rb
masterview-0.2.0 lib/masterview/directives/block.rb
masterview-0.0.9 lib/masterview/directives/block.rb
masterview-0.1.3 lib/masterview/directives/block.rb
masterview-0.1.5 lib/masterview/directives/block.rb
masterview-0.1.2 lib/masterview/directives/block.rb
masterview-0.0.7 lib/masterview/directives/block.rb
masterview-0.0.8 lib/masterview/directives/block.rb
masterview-0.2.5 lib/masterview/directives/block.rb