Sha256: f40303e6da427481d614b16d53e573a11d298afd51870bd7632fe6f060114af6

Contents?: true

Size: 855 Bytes

Versions: 4

Compression:

Stored size: 855 Bytes

Contents

class ComfortableMexicanSofa::Content::Tag

  class Error < StandardError; end

  attr_reader :context, :params, :source

  def initialize(context:, params: [], source: nil)
    @context  = context
    @params   = params
    @source   = source
  end

  # Making sure we don't leak erb from tags by accident.
  # Tag classes can override this, like partials/helpers tags.
  def allow_erb
    false || ComfortableMexicanSofa.config.allow_erb
  end

  # Normally it's a string. However if tag content has tags, we need to expand
  # them and that produces potentually more stuff
  def nodes
    template  = ComfortableMexicanSofa::Content::Renderer.new(@context)
    tokens    = template.tokenize(content)
    template.nodes(tokens)
  end

  def content
    raise Error, "This is a base class. It holds no content"
  end

  def render
    content
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.12 lib/comfortable_mexican_sofa/content/tag.rb
comfortable_mexican_sofa-2.0.11 lib/comfortable_mexican_sofa/content/tag.rb
comfortable_mexican_sofa-2.0.10 lib/comfortable_mexican_sofa/content/tag.rb
comfortable_mexican_sofa-2.0.9 lib/comfortable_mexican_sofa/content/tag.rb