Class: Puppet::Pops::Evaluator::EppEvaluator
- Defined in:
- lib/puppet/pops/evaluator/epp_evaluator.rb
Overview
Handler of Epp call/evaluation from the epp and inline_epp functions
Class Method Summary collapse
- .epp(scope, file, env_name, template_args = nil) ⇒ Object
- .inline_epp(scope, epp_source, template_args = nil) ⇒ Object
Class Method Details
.epp(scope, file, env_name, template_args = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/puppet/pops/evaluator/epp_evaluator.rb', line 22 def self.epp(scope, file, env_name, template_args = nil) unless file.is_a?(String) raise ArgumentError, "epp(): the first argument must be a String with the filename, got a #{file.class}" end unless Puppet::FileSystem.exist?(file) unless file =~ /\.epp$/ file = file + ".epp" end end scope.debug "Retrieving epp template #{file}" template_file = Puppet::Parser::Files.find_template(file, env_name) if template_file.nil? || !Puppet::FileSystem.exist?(template_file) raise Puppet::ParseError, _("Could not find template '%{file}'") % { file: file } end # Parse and validate the source parser = Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new begin result = parser.parse_file(template_file) rescue Puppet::ParseError => e raise ArgumentError, "epp(): Invalid EPP: #{e.}" end # Evaluate (and check template_args) evaluate(parser, 'epp', scope, true, result, template_args) end |
.inline_epp(scope, epp_source, template_args = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/puppet/pops/evaluator/epp_evaluator.rb', line 5 def self.inline_epp(scope, epp_source, template_args = nil) unless epp_source.is_a?(String) raise ArgumentError, "inline_epp(): the first argument must be a String with the epp source text, got a #{epp_source.class}" end # Parse and validate the source parser = Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new begin result = parser.parse_string(epp_source, 'inlined-epp-text') rescue Puppet::ParseError => e raise ArgumentError, "inline_epp(): Invalid EPP: #{e.}" end # Evaluate (and check template_args) evaluate(parser, 'inline_epp', scope, false, result, template_args) end |