Class: Snp::Compiler
- Inherits:
-
Object
- Object
- Snp::Compiler
- Defined in:
- lib/snp/compiler.rb
Overview
Snp::Compiler
This class takes a template file name and builds it, using the template definition, default data to be used and extra options that override the default ones.
Example
Compiler.build('js.html', inline: true)
Class Method Summary collapse
Instance Method Summary collapse
-
#compile ⇒ Object
Public: actually compiles the template.
-
#initialize(template, extra_options) ⇒ Compiler
constructor
Public: creates a new Snp::Compiler instance.
Constructor Details
#initialize(template, extra_options) ⇒ Compiler
Public: creates a new Snp::Compiler instance.
template - the template name. extra_options - options to override default data to build the template.
22 23 24 25 |
# File 'lib/snp/compiler.rb', line 22 def initialize(template, ) @template = template @options = end |
Class Method Details
.build(template_name, extra_options) ⇒ Object
14 15 16 |
# File 'lib/snp/compiler.rb', line 14 def self.build(template_name, ) new(template_name, ).compile end |
Instance Method Details
#compile ⇒ Object
Public: actually compiles the template.
Returns a string with the compiled version of the snippet.
30 31 32 |
# File 'lib/snp/compiler.rb', line 30 def compile template.compile(compilation_context) end |