class ComfortableMexicanSofa::Content::Tag

Attributes

context[R]

@type [Comfy::Cms::WithFragments]

params[R]

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

source[R]

@type [String, nil] source

Public Class Methods

new(context:, params: [], source: nil) click to toggle source

@param [Comfy::Cms::WithFragments] context @param [Array<String, {String => String}>] params @param [String, nil] source

# File lib/comfortable_mexican_sofa/content/tag.rb, line 19
def initialize(context:, params: [], source: nil)
  @context  = context
  @params   = params
  @source   = source
end

Public Instance Methods

allow_erb?() click to toggle source

Making sure we don't leak erb from tags by accident. Tag classes can override this, like partials/helpers tags.

# File lib/comfortable_mexican_sofa/content/tag.rb, line 27
def allow_erb?
  ComfortableMexicanSofa.config.allow_erb
end
content() click to toggle source

@return [String]

# File lib/comfortable_mexican_sofa/content/tag.rb, line 41
def content
  raise Error, "This is a base class. It holds no content"
end
nodes() click to toggle source

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>]

# File lib/comfortable_mexican_sofa/content/tag.rb, line 34
def nodes
  template  = ComfortableMexicanSofa::Content::Renderer.new(@context)
  tokens    = template.tokenize(content)
  template.nodes(tokens)
end
render() click to toggle source

@return [String]

# File lib/comfortable_mexican_sofa/content/tag.rb, line 46
def render
  content
end