Sha256: dec73e5db072f6a24120caa2e43ce16d5eb7e741a0ee89c306cfa92b0097875d

Contents?: true

Size: 776 Bytes

Versions: 7

Compression:

Stored size: 776 Bytes

Contents

module MasterView
  module Directives

    # omit tag if attr_value is empty or if at runtime the condition evaluates to true
    # mv:omit_tag="" will not render the tag,
    # mv:omit_tag="true" will not render the tag,
    # mv:omit_tag="false" will render the tag
    class Omit_tag < MasterView::DirectiveBase
      def priority
        DirectivePriorities::UltraLow
      end

      def stag(dcs)
        ret = []
        unless attr_value.empty?
          ret << erb('if '+attr_value)
          ret << dcs.render
          ret << erb('end')
        end
      end

      def etag(dcs)
        ret = []
        unless attr_value.empty?
          ret << erb('if '+attr_value)
          ret << dcs.render
          ret << erb('end')
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
masterview-0.2.1 lib/masterview/directives/omit_tag.rb
masterview-0.1.5 lib/masterview/directives/omit_tag.rb
masterview-0.2.0 lib/masterview/directives/omit_tag.rb
masterview-0.2.2 lib/masterview/directives/omit_tag.rb
masterview-0.2.3 lib/masterview/directives/omit_tag.rb
masterview-0.2.4 lib/masterview/directives/omit_tag.rb
masterview-0.2.5 lib/masterview/directives/omit_tag.rb