Sha256: b1405ac525c99575a25e570ffa8dc80648f56f6e8f4beeb9158f2183de9e5c3e

Contents?: true

Size: 844 Bytes

Versions: 5

Compression:

Stored size: 844 Bytes

Contents

module MasterView
  module Directives

    # outputs an else/end block around the text tags removing previous end tag (from if/elsif)
    #
    class Else < MasterView::DirectiveBase

      metadata :priority => 'High',
        :category => 'erb',
        :description => 'Used in conjunction with the mv:if and mv:elsif directives to allow you to create if... elsif... else... end blocks'

      # remove the last <% end -%> from the parent tag's content and add a <% else -%> instead.
      # This is a continuation of previous if or elsif statement.
      event :before_stag do
        tag = @directive_call_stack.context[:tag]
        delete_last_in_parent(tag, erb_eval('end') )
        render erb_eval( 'else' )
      end

      # output <% end -%>
      event :after_etag do
        render erb_eval( 'end' )
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
masterview-0.3.0 lib/masterview/directives/else.rb
masterview-0.3.1 lib/masterview/directives/else.rb
masterview-0.3.2 lib/masterview/directives/else.rb
masterview-0.3.3 lib/masterview/directives/else.rb
masterview-0.3.4 lib/masterview/directives/else.rb