Create a new Template expression

@param cl type of expression
@param template template
@param args template parameters
@return template expression
978600
public static <T extends Comparable<?>> DateTimeTemplate<T> dateTimeTemplate(Class<? extends T> cl, String template, List<?> args) {
        return dateTimeTemplate(cl, createTemplate(template), args);
    }
990175
public static PredicateTemplate predicateTemplate(Template template, Object... args) {
        return predicateTemplate(template, ImmutableList.copyOf(args));
    }
1240562
function Templater(options) {
  if (options == null) {
    options = { allowEval: true };
  }
  this.options = options;
  if (options.stack && Array.isArray(options.stack)) {
    this.stack = options.stack;
  }
  else if (typeof options.stack === 'string') {
    this.stack = [ options.stack ];
  }
  else {
    this.stack = [];
  }
  this.nodes = [];
}
1194852
@Deprecated
    public static <T extends Comparable<?>> DateTimeTemplate<T> dateTimeTemplate(Class<? extends T> cl,
                                                                                 String template, ImmutableList<?> args) {
        return dateTimeTemplate(cl, createTemplate(template), args);
    }
799590
function template(templateSpec, env) {
            /* istanbul ignore next */
            if (!env) {
                throw new Exception("No environment passed to template");
            }
            if (!templateSpec || !templateSpec.main) {
                throw new Exception('Unknown template object: ' + typeof templateSpec);
            }

            // Note: Using env.VM references rather than local var references throughout this section to allow
            // for external users to override these as psuedo-supported APIs.
            env.VM.checkRevision(templateSpec.compiler);

            var invokePartialWrapper = function(partial, indent, name, context, hash, helpers, partials, data, depths) {
                if (hash) {
                    context = Utils.extend({}, context, hash);
                }

                var result = env.VM.invokePartial.call(this, partial, name, context, helpers, partials, data, depths);

                if (result == null && env.compile) {
                    var options = { helpers: helpers, partials: partials, data: data, depths: depths };
                    partials[name] = env.compile(partial, { data: data !== undefined, compat: templateSpec.compat }, env);
                    result = partials[name](context, options);
                }
                if (result != null) {
                    if (indent) {
                        var lines = result.split('\n');
                        for (var i = 0, l = lines.length; i < l; i++) {
                            if (!lines[i] && i + 1 === l) {
                                break;
                            }

                            lines[i] = indent + lines[i];
                        }
                        result = lines.join('\n');
                    }
                    return result;
                } else {
                    throw new Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
                }
            };

            // Just add water
            var container = {
                lookup: function(depths, name) {
                    var len = depths.length;
                    for (var i = 0; i < len; i++) {
                        if (depths[i] && depths[i][name] != null) {
                            return depths[i][name];
                        }
                    }
                },
                lambda: function(current, context) {
                    return typeof current === 'function' ? current.call(context) : current;
                },

                escapeExpression: Utils.escapeExpression,
                invokePartial: invokePartialWrapper,

                fn: function(i) {
                    return templateSpec[i];
                },

                programs: [],
                program: function(i, data, depths) {
                    var programWrapper = this.programs[i],
                        fn = this.fn(i);
                    if (data || depths) {
                        programWrapper = program(this, i, fn, data, depths);
                    } else if (!programWrapper) {
                        programWrapper = this.programs[i] = program(this, i, fn);
                    }
                    return programWrapper;
                },

                data: function(data, depth) {
                    while (data && depth--) {
                        data = data._parent;
                    }
                    return data;
                },
                merge: function(param, common) {
                    var ret = param || common;

                    if (param && common && (param !== common)) {
                        ret = Utils.extend({}, common, param);
                    }

                    return ret;
                },

                noop: env.VM.noop,
                compilerInfo: templateSpec.compiler
            };

            var ret = function(context, options) {
                options = options || {};
                var data = options.data;

                ret._setup(options);
                if (!options.partial && templateSpec.useData) {
                    data = initData(context, data);
                }
                var depths;
                if (templateSpec.useDepths) {
                    depths = options.depths ? [context].concat(options.depths) : [context];
                }

                return templateSpec.main.call(container, context, container.helpers, container.partials, data, depths);
            };
            ret.isTop = true;

            ret._setup = function(options) {
                if (!options.partial) {
                    container.helpers = container.merge(options.helpers, env.helpers);

                    if (templateSpec.usePartial) {
                        container.partials = container.merge(options.partials, env.partials);
                    }
                } else {
                    container.helpers = options.helpers;
                    container.partials = options.partials;
                }
            };

            ret._child = function(i, data, depths) {
                if (templateSpec.useDepths && !depths) {
                    throw new Exception('must pass parent depths');
                }

                return program(container, i, templateSpec[i], data, depths);
            };
            return ret;
        }
1102647
public static <T extends Comparable<?>> TimeTemplate<T> timeTemplate(Class<? extends T> cl, String template, List<?> args) {
        return timeTemplate(cl, createTemplate(template), args);
    }
625345
public TemplateHelper cls(String name) {
        String newClassName = name + "$" + COUNT.getAndIncrement();

        thisClass = pool.makeClass(newClassName);
        className = thisClass.getSimpleName();

        return this;
    }
745075
@Deprecated
    public static <T extends Comparable<?>> TimeTemplate<T> timeTemplate(Class<? extends T> cl,
                                                                         Template template, ImmutableList<?> args) {
        return new TimeTemplate<T>(cl, template, args);
    }
606353
public static <T extends Comparable<?>> TimeTemplate<T> timeTemplate(Class<? extends T> cl,
                                                                         Template template, Object... args) {
        return timeTemplate(cl, template, ImmutableList.copyOf(args));
    }
698324
public static <T> TemplateExpression<T> template(Class<? extends T> cl, Template template, Object... args) {
        return template(cl, template, ImmutableList.copyOf(args));
    }
3149
function getTemplate(template, options) {
  stack.clear();
  parser.reset();

  let opts = typeof options === 'undefined' ? {} : options;
  opts.strict = typeof opts.strict === 'boolean' ? opts.strict : true;
  opts.preserveWhitespace = typeof opts.preserveWhitespace === 'boolean' ? opts.preserveWhitespace : false;
  opts.validateHtml = opts.validateHtml != null ? opts.validateHtml : 'strict';
  opts.logger = opts.logger != null ? opts.logger : {};

  let lambdas = {};
  if (_.isArray(opts.lambdas)) {
    for (let i = 0; i < opts.lambdas.length; i++) {
      lambdas[opts.lambdas[i]] = true;
    }
  }
  opts.lambdas = lambdas;
  opts.processingHTML = typeof opts.processingHTML === 'boolean' ? opts.processingHTML : true;

  compilerLogger.setStrictMode(opts.strict);
  compilerLogger.setOverrides(opts.logger);
  stack.setHtmlValidation(opts.validateHtml);

  let templateStr = template.toString();

  processTemplate(templateStr, opts);

  let output = {};

  if (stack.stack.length > 0) {
    compilerErrors.notAllTagsWereClosedProperly(stack.stack);
  }

  parser.end();
  output.templateObj = stack.getOutput();
  const Template = require('../template');
  output.template = new Template(output.templateObj);
  output.source = template;
  output.tokens = {};
  _.each(stack.tokens, function(values, type) {
    output.tokens[type] = _.keys(values);
  });
  return output;
}
719776
public static RegexPathTemplate create(String urlTemplate) {
        StringBuffer baseUrl = new StringBuffer();
        Map<String, PathTemplate> templates = new HashMap<String, PathTemplate>();
        CurlyBraceTokenizer t = new CurlyBraceTokenizer(urlTemplate);
        while (t.hasNext()) {
            String tok = t.next();
            if (CurlyBraceTokenizer.insideBraces(tok)) {
                tok = CurlyBraceTokenizer.stripBraces(tok);

                int index = tok.indexOf(':'); // first index of : as it can't appears in the name
                String name;
                Pattern validationPattern;
                if(index > -1) {
                    name = tok.substring(0, index);
                    validationPattern = Pattern.compile("^" + tok.substring(index + 1) + "$");
                }else{
                    name = tok;
                    validationPattern = DEFAULT_VALIDATION_PATTERN;
                }
                Validate.isTrue(TEMPLATE_NAME_PATTERN.matcher(name).matches(), "Template name '%s' doesn't match the expected format: %s", name, TEMPLATE_NAME_PATTERN);
                Validate.isFalse(templates.containsKey(name), "Template name '%s' is already defined!", name);
                templates.put(name, new PathTemplate(name, validationPattern));
                baseUrl.append("{").append(name).append("}");
            } else {
                baseUrl.append(tok);
            }
        }
        String url = baseUrl.toString();
        isTrue(!Urls.hasQueryString(url), "Given url contains a query string: %s", url);
        return new RegexPathTemplate(url, templates);
    }
524099
public static Object formatL(final String template, final Object... args) {
    return new Object() {
      @Override
      public String toString() {
        return format(template, args);
      }
    };
  }
61735
function(tplname, tplargs, tplloader) {
            tplname = tplname || this.template;
            tplargs = tplargs || _.result(this, "templateContext");
            tplloader = tplloader || _.result(this, "templateLoader");

            var tpl = new Template({
                template: tplname,
                args: tplargs,
                loader: tplloader,
                view: this
            });
            return tpl.render();
        }
45488
public static <T extends Comparable<?>> DateTemplate<T> dateTemplate(Class<? extends T> cl, Template template, List<?> args) {
        return new DateTemplate<T>(cl, template, ImmutableList.copyOf(args));
    }
1110853
public static <T extends Number & Comparable<?>> NumberTemplate<T> numberTemplate(Class<? extends T> cl, Template template, List<?> args) {
        return new NumberTemplate<T>(cl, template, ImmutableList.copyOf(args));
    }
1117946
def _build_new_template(self, stack, parameters):
        
        log_lines = ["New template parameters:"]
        for param in sorted(parameters,
                            key=lambda param: param['ParameterKey']):
            log_lines.append("%s = %s" % (param['ParameterKey'],
                                          param['ParameterValue']))

        log_lines.append("\nNew template contents:")
        log_lines.append("".join(stack))
        return log_lines