Class: Template
- Inherits:
-
Object
- Object
- Template
- Defined in:
- lib/template.rb,
lib/template/node.rb,
lib/template/parser.rb,
lib/template/node/part.rb,
lib/template/node/template.rb,
lib/template/node/code_part.rb,
lib/template/node/text_part.rb,
lib/template/parser/template.rb
Defined Under Namespace
Constant Summary collapse
- GLOBALS =
%i[output error context object].freeze
- DEFAULT_TIMEOUT =
0
- Version =
Gem::Version.new(File.read(File.("../../VERSION", __dir__)))
Class Method Summary collapse
- .evaluate(input, output: StringIO.new, error: StringIO.new, timeout: DEFAULT_TIMEOUT) ⇒ Object
- .parse(input, timeout: DEFAULT_TIMEOUT) ⇒ Object
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(input, output: StringIO.new, error: StringIO.new, timeout: DEFAULT_TIMEOUT) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(input, output: StringIO.new, error: StringIO.new, timeout: DEFAULT_TIMEOUT) ⇒ Template
Returns a new instance of Template.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/template.rb', line 7 def initialize( input, output: StringIO.new, error: StringIO.new, timeout: DEFAULT_TIMEOUT ) @input = input @output = output @error = error @timeout = timeout || DEFAULT_TIMEOUT @context = ::Code::Object::Context.new end |
Class Method Details
.evaluate(input, output: StringIO.new, error: StringIO.new, timeout: DEFAULT_TIMEOUT) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/template.rb', line 24 def self.evaluate( input, output: StringIO.new, error: StringIO.new, timeout: DEFAULT_TIMEOUT ) new(input, output:, error:, timeout:).evaluate end |
.parse(input, timeout: DEFAULT_TIMEOUT) ⇒ Object
20 21 22 |
# File 'lib/template.rb', line 20 def self.parse(input, timeout: DEFAULT_TIMEOUT) Timeout.timeout(timeout) { Parser.parse(input).to_raw } end |