Sha256: c0df4e79b86edfbe2e81faaec77aeff9455410f9823f1c210e3eb769dc74caba

Contents?: true

Size: 659 Bytes

Versions: 5

Compression:

Stored size: 659 Bytes

Contents

module Garterbelt
  class Text < Renderer
    attr_accessor :content
    
    def initialize(opts)
      super
      raise ArgumentError, ":content option required for #{self.class} initialization" unless opts[:content]
      self.content = opts[:content]
    end
    
    def raise_with_block_content
      raise ArgumentError, "#{self.class} does not take block content" if self.content.is_a?(Proc)
    end
    
    def render
      raise_with_block_content
      output << "#{indent}#{escaped_content}\n"
    end
    
    def escaped_content
      escape? ? ERB::Util.h(content) : content
    end
    
    def escape?
      !!view.escape
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
garterbelt-0.0.6 lib/renderers/text.rb
garterbelt-0.0.5 lib/renderers/text.rb
garterbelt-0.0.4 lib/renderers/text.rb
garterbelt-0.0.3 lib/renderers/text.rb
garterbelt-0.0.2 lib/renderers/text.rb