Sha256: 240a0f8554e8b7eb7dd4f936ef1a6836405d6c69d9f4e944d6db72cb4c2d2a31

Contents?: true

Size: 973 Bytes

Versions: 2

Compression:

Stored size: 973 Bytes

Contents

require 'glimmer/dsl/expression'
require 'glimmer/dsl/web/general_element_expression'

module Glimmer
  module DSL
    module Web
      class StyleExpression < Expression
        include GeneralElementExpression
        include Glimmer
        
        def can_interpret?(parent, keyword, *args, &block)
          keyword == 'style' &&
            !block.nil?
        end
        
        def add_content(parent, keyword, *args, &block)
          if parent.rendered? || parent.skip_content_on_render_blocks?
            return_value = css(&block).to_s
            return_value = super(parent, keyword, *args, &block) if return_value.to_s.empty?
            if return_value.is_a?(String) && parent.dom_element.text.to_s.empty?
              parent.add_text_content(return_value)
            end
            parent.post_add_content
            return_value
          else
            parent.add_content_on_render(&block)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
glimmer-dsl-web-0.2.8 lib/glimmer/dsl/web/style_expression.rb
glimmer-dsl-web-0.2.7 lib/glimmer/dsl/web/style_expression.rb