class Babl::Builder::TemplateBase

TemplateBase is a thin wrapper around Builder.

Since the BABL code is run via instance_exec within an instance of this class, we want to define as few methods as possible here.

Attributes

builder[R]

Public Class Methods

new(builder = ChainBuilder.new(&:itself)) click to toggle source
# File lib/babl/builder/template_base.rb, line 14
def initialize(builder = ChainBuilder.new(&:itself))
    @builder = builder
    freeze
end
unscoped() click to toggle source
# File lib/babl/builder/template_base.rb, line 33
def self.unscoped
    @unscoped ||= new
end

Public Instance Methods

compile(preloader: Rendering::NoopPreloader, pretty: true, optimize: true, lookup_context: nil) click to toggle source
# File lib/babl/builder/template_base.rb, line 19
def compile(preloader: Rendering::NoopPreloader, pretty: true, optimize: true, lookup_context: nil)
    tree = precompile(Nodes::TerminalValue.instance, lookup_context: lookup_context)
    tree = tree.optimize if optimize
    validate(tree)

    Rendering::CompiledTemplate.with(
        preloader: preloader,
        pretty: pretty,
        node: tree,
        dependencies: tree.dependencies,
        schema: tree.schema
    )
end
unscoped() click to toggle source
# File lib/babl/builder/template_base.rb, line 37
def unscoped
    self.class.unscoped
end

Protected Instance Methods

construct_context(&block) click to toggle source
# File lib/babl/builder/template_base.rb, line 57
def construct_context(&block)
    self.class.new builder.construct_context(&block)
end
construct_node(&block) click to toggle source
# File lib/babl/builder/template_base.rb, line 53
def construct_node(&block)
    self.class.new builder.construct_node(&block)
end
construct_terminal(&block) click to toggle source
# File lib/babl/builder/template_base.rb, line 61
def construct_terminal(&block)
    self.class.new builder.construct_terminal(&block)
end
precompile(node, context) click to toggle source
# File lib/babl/builder/template_base.rb, line 49
def precompile(node, context)
    builder.precompile(node, context)
end
validate(tree) click to toggle source
# File lib/babl/builder/template_base.rb, line 45
def validate(tree)
    # NOOP
end