Sha256: 0a0a09e7bf3c2fc4ee02302edfdf3d0022ee0cff59b8e83379ca8c6e1dcb8f80

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

module Garterbelt
  class Text < Renderer
    attr_accessor :content
    
    def initialize(opts)
      super
      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
      str = template
      output << str
      str
    end
    
    def escaped_content
      if escape
        str = ERB::Util.h(content)
        if style == :pretty
          str = str.wrap(Garterbelt.wrap_length, :indent => indent)
        end
        str
      else
        content
      end
    end
    
    def line_end
      style == :compact ? '' : super
    end
    
    def template
      "#{escaped_content}#{line_end}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
garterbelt-0.1.1 lib/renderers/text.rb