Sha256: c4e56c051750bacd93aa18cb908cb9694ce5208dc760e8881f3c468773b6b590

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

module Garterbelt
  class Text < Renderer
    attr_accessor :content, :escape
    
    def initialize(opts)
      super
      raise ArgumentError, ":content option required for #{self.class} initialization" unless opts[:content]
      self.content = opts[:content]
      self.escape = view.escape
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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