Sha256: b64d34a27a1b1b6927db0daa11038b3b88dd816fcb55cbca8fbad0d473561630

Contents?: true

Size: 1.25 KB

Versions: 17

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

class ComfortableMexicanSofa::Content::Tag

  class Error < StandardError; end

  # @type [Comfy::Cms::WithFragments]
  attr_reader :context

  # @type [Array<String, {String => String}>] params
  attr_reader :params

  # @type [String, nil] source
  attr_reader :source

  # @param [Comfy::Cms::WithFragments] context
  # @param [Array<String, {String => String}>] params
  # @param [String, nil] 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?
    ComfortableMexicanSofa.config.allow_erb
  end

  # Normally it's a {(String)}. However, if tag content has tags,
  # we need to expand them and that produces potentially more stuff.
  # @return [Array<String, ComfortableMexicanSofa::Content::Tag>]
  def nodes
    template  = ComfortableMexicanSofa::Content::Renderer.new(@context)
    tokens    = template.tokenize(content)
    template.nodes(tokens)
  end

  # @return [String]
  def content
    raise Error, "This is a base class. It holds no content"
  end

  # @return [String]
  def render
    content
  end

end

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
comfortable_mexican_sofa-2.0.19 lib/comfortable_mexican_sofa/content/tag.rb
PixelForce_ETS-0.0.2 lib/comfortable_mexican_sofa/content/tag.rb
PixelForce_ETS-0.0.1 lib/comfortable_mexican_sofa/content/tag.rb
kcyEtsTest2-0.0.4 lib/comfortable_mexican_sofa/content/tag.rb
kcyEtsTest2-0.0.3 lib/comfortable_mexican_sofa/content/tag.rb
kcyEtsTest2-0.0.2 lib/comfortable_mexican_sofa/content/tag.rb
kcyEtsTest2-0.0.1 lib/comfortable_mexican_sofa/content/tag.rb
kcyEtsTest-0.0.1 lib/comfortable_mexican_sofa/content/tag.rb
kcyEtsTest-2.2.19 lib/comfortable_mexican_sofa/content/tag.rb
ComfortableMexicanSofa-2.0.18 lib/comfortable_mexican_sofa/content/tag.rb
kcy1-1.0 lib/comfortable_mexican_sofa/content/tag.rb
comfortable_mexican_sofa-2.0.18 lib/comfortable_mexican_sofa/content/tag.rb
comfortable_mexican_sofa-2.0.17 lib/comfortable_mexican_sofa/content/tag.rb
comfortable_mexican_sofa-2.0.16 lib/comfortable_mexican_sofa/content/tag.rb
comfortable_mexican_sofa-2.0.15 lib/comfortable_mexican_sofa/content/tag.rb
comfortable_mexican_sofa-2.0.14 lib/comfortable_mexican_sofa/content/tag.rb
comfortable_mexican_sofa-2.0.13 lib/comfortable_mexican_sofa/content/tag.rb