class Bytewise::Ast::Reference
This is the most basic class It is designed to be extended by tags, chunk, body, blocks, etc.
Attributes
filter[R]
name[R]
raw[R]
Public Class Methods
new(name, filter = nil, context = :default)
click to toggle source
# File lib/brace_markup/ast/reference.rb, line 10 def initialize(name, filter = nil, context = :default) @name = name @filter = filter @context = context end
Public Instance Methods
render(ctx, *args)
click to toggle source
# File lib/brace_markup/ast/reference.rb, line 34 def render(ctx, *args) value = ctx.resolve_reference(@name) # Escape HTML if not raw and not inside a bracket if @context == :default && !value.nil? && value.is_a?(String) value = ::CGI::escapeHTML(value) end unless @filter.nil? value = ::Bytewise::Filters::Filter.apply(filter, input: value, reference: self) end value end
to_s()
click to toggle source
Todo: Update this method to match the new context - approach
# File lib/brace_markup/ast/reference.rb, line 19 def to_s string = '{{' string += '{' if @raw string += " #{@name}" unless @filter.nil? && @filter != '' string += "|#{@filter}" end string += ' }}' string += '}' if @raw string end