Class: Babl::Builder::TemplateBase
- Inherits:
-
Object
- Object
- Babl::Builder::TemplateBase
- Defined in:
- lib/babl/builder/template_base.rb
Overview
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.
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #compile(preloader: Rendering::NoopPreloader, pretty: true, optimize: true, lookup_context: nil) ⇒ Object
-
#initialize(builder = ChainBuilder.new(&:itself)) ⇒ TemplateBase
constructor
A new instance of TemplateBase.
- #unscoped ⇒ Object
Constructor Details
#initialize(builder = ChainBuilder.new(&:itself)) ⇒ TemplateBase
Returns a new instance of TemplateBase.
14 15 16 17 |
# File 'lib/babl/builder/template_base.rb', line 14 def initialize(builder = ChainBuilder.new(&:itself)) @builder = builder freeze end |
Class Method Details
.unscoped ⇒ Object
33 34 35 |
# File 'lib/babl/builder/template_base.rb', line 33 def self.unscoped @unscoped ||= new end |
Instance Method Details
#compile(preloader: Rendering::NoopPreloader, pretty: true, optimize: true, lookup_context: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 ⇒ Object
37 38 39 |
# File 'lib/babl/builder/template_base.rb', line 37 def unscoped self.class.unscoped end |