Class: Marko::Services::Compile
- Inherits:
-
Marko::Service
- Object
- Marko::Service
- Marko::Services::Compile
- Defined in:
- lib/marko/services/compile.rb
Overview
Compitation service
Constant Summary
Constants inherited from Marko::Service
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(tree: nil, template: '', filename: '', &block) ⇒ Compile
constructor
A new instance of Compile.
Methods inherited from Marko::Service
Constructor Details
#initialize(tree: nil, template: '', filename: '', &block) ⇒ Compile
Returns a new instance of Compile.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/marko/services/compile.rb', line 9 def initialize(tree: nil, template: '', filename: '', &block) @tree = MustbeTreeNode.(tree) if tree @template = MustbeString.(template) @filename = MustbeString.(filename) @block = block art = Marko.artifact @template = art.template if @template.empty? @filename = art.filename if @filename.empty? end |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/marko/services/compile.rb', line 20 def call storage = StoragePlug.plugged compiler = CompilerPlug.plugged erb = storage.content(@template) @tree = Assembler.(&@block) unless @tree compiler.(@tree, erb, @filename, &@block) # => filename end |