Skip to content

Instantly share code, notes, and snippets.

@wytten
Created April 21, 2014 19:35
Show Gist options
  • Select an option

  • Save wytten/11153842 to your computer and use it in GitHub Desktop.

Select an option

Save wytten/11153842 to your computer and use it in GitHub Desktop.
Perl Template
printjson(db.GroovyScriptResult.findOne({name : "[%script%]", version : "[%version%]", database : "[%database%]", stackTrace:null}))
use Template;
# some useful options (see below for full list)
my $config = {
# INCLUDE_PATH => '/search/path', # or list ref
# INTERPOLATE => 1, # expand "$var" in plain text
# POST_CHOMP => 1, # cleanup whitespace
# PRE_PROCESS => 'header', # prefix each template
# EVAL_PERL => 1, # evaluate Perl code blocks
};
# create Template object
my $template = Template->new($config);
# define template variables for replacement
my $vars = {
version => $ARGV[0],
database => $ARGV[1],
script => $ARGV[2],
};
# specify input filename, or file handle, text reference, etc.
my $input = 'Query-template.js';
# process input template, substituting variables
$template->process($input, $vars)
|| die $template->error();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment