class Bytewise::Ast::Tag

This is a basic tag @abstract

Constants

ALLOWED_TAGS_NAMES

@deprecated

TAGS

Attributes

arguments[R]
body[R]
name[R]
sections[R]

Public Class Methods

create(type, ** args) click to toggle source

Creates a tag from the tag identifier (+, >, <, #, etc.)

# File lib/brace_markup/ast/tag.rb, line 26
def self.create(type, ** args)
  if TAGS.key? type
    klass = Object.const_get(TAGS[type])
    klass.new(** args)
  else
    raise Exception.new("Unknown tag type '#{type.to_s}'")
  end
end
map(type) click to toggle source

Registers a tag with a given name

# File lib/brace_markup/ast/tag.rb, line 17
def self.map(type)
  type = type.to_sym if type.is_a? String

  TAGS[type] = self.name
end
new(name:, arguments: {}, body: nil, sections: {}) click to toggle source
# File lib/brace_markup/ast/tag.rb, line 35
def initialize(name:, arguments: {}, body: nil, sections: {})
  @name = name
  @body = body
  @sections = sections
  @arguments = arguments
end

Public Instance Methods

render_arguments(*args) click to toggle source
# File lib/brace_markup/ast/tag.rb, line 42
def render_arguments(*args)
  rendered_arguments = {}

  @arguments.each_pair do |key, value|
    if value.is_a? Node
      rendered_arguments[key] = value.render(*args)
    else
      rendered_arguments[key] = value
    end
  end

  rendered_arguments
end