All pastes #507368 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-24 14:44 UTC
rendered paste body
#!/usr/bin/ruby

module Puppet::Parser::Functions
  newfunction(:template_with_check) do |args|
        tmpl = args[0]
        checkscript = args[1]
#       tmpfile = generate("mktemp /tmp/template.XXXXXX")
        tmpfile = "/tmp/template.tmp"
        content = template(tmpl)
        File.open(tmpfile, 'a') {|fd| fd.puts content }
        if generate(checkscript tmpfile)
#               return(file(tmpfile))
                return 0
        end
#               return("Error: could not validate file")
        return 1
  end
end