Generate templated file with handlebars
@param model Model
@param template Template
@return Rendered markup
559126
private String render(io.wcm.caravan.hal.docs.impl.model.Service service, Map<String, Object> model,
      Template template) throws IOException {
    Map<String, Object> mergedModel = ImmutableMap.<String, Object>builder()
        .putAll(model)
        .put("docsContext", ImmutableMap.<String, Object>builder()
            .put("baseUrl", DocsPath.get(service.getServiceId()) + "/")
            .put("resourcesPath", HalDocsBundleTracker.DOCS_RESOURCES_URI_PREFIX)
            .build())
        .build();
    return template.apply(mergedModel);
  }
488513
def process_templates(input_dir, target_dir, context):
    
    if not target_dir.endswith('/'):
        target_dir = "{}/".format(target_dir)
    if not os.path.exists(target_dir):
        LOGGER.info('Creating: {}'.format(target_dir))
        os.makedirs(target_dir)
    replicate_directory_tree(input_dir, target_dir)
    templates = find_templates(input_dir)
    for templ in templates:
        output_file = templ.replace(input_dir, target_dir)
        output_file = output_file[:-len('.mustache')]
        render_template(templ,  output_file, context)
788996
public Writer withTemplate(File template) {
        if (null == template || !template.exists()) {
            throw new IllegalArgumentException("template file not exist");
        }
        this.template = template;
        return this;
    }
1258549
function renderTemplate(fragment, templateName) {
    if (templateName === 'none') return fragment._txt;
    var t = generator.template$[templateName];
    if (!t) {
      log('Unknown template %s for %s, using default.', templateName, fragment._href);
      t = generator.template$.default;
    }

    var out;
    try { out = t(fragment); }
    catch(err) {
      var msg = u.format('Error rendering %s\n\ntemplate: %s\n',
                         fragment._href, templateName, err.stack || err);
      log(msg);
      out = opts.production ? '' : '<pre>' + esc(msg) + '</pre>';
    }

    return out;
  }
538596
public static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, List<?> args) {
        return template(cl, TemplateFactory.DEFAULT.create(template), args);
    }
324196
public String render(String templateName, EmailModel emailModel, Map<String, Object> model, Locale locale) {

		if (logger.isDebugEnabled()) {
			logger.debug("Rendering template [{}] for recipient [{}]", templateName, emailModel.getTo());
		}

		final IEngineConfiguration engineConfiguration = templateEngineFactory.getTemplateEngine().getConfiguration();
		final ExpressionContext context = new ExpressionContext(engineConfiguration, locale);

        context.setVariable(ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME,
                new ThymeleafEvaluationContext(applicationContext, null));

		context.setVariables(model);
		context.setVariable(THYMELEAF_EMAIL_MODEL_NAME, emailModel);
		return templateEngineFactory.getTemplateEngine().process(templateName, context);
	}
628932
public static String render(Template template, Map<String, Object> bindingMap) {
		template.binding(bindingMap);
		return template.render();
	}
1208256
function render_file(locals, cb) {
    // cached?
    var template = cache[filename];
    if (template) {
      return cb(null, template(locals, handlebarsOpts));
    }

    fs.readFile(filename, 'utf8', function(err, str){
      if (err) {
        return cb(err);
      }

      var template = handlebars.compile(str);
      if (locals.cache) {
        cache[filename] = template;
      }

      try {
        var res = template(locals, handlebarsOpts);
        self.async.done(function(values) {
          Object.keys(values).forEach(function(id) {
            res = res.replace(id, values[id]);
          });

          cb(null, res);
        });
      } catch (err) {
        err.message = filename + ': ' + err.message;
        cb(err);
      }
    });
  }
518536
public JsonResponse getTemplate(String template) throws IOException {
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(Template.PARAM_TEMPLATE, template);
        return apiGet(ApiAction.template, data);
    }
1280105
def render(template, **kwargs):
    
    import jinja2
    import os.path as path

    searchpath = path.join(path.dirname(__file__), 
        "templates") 
    loader = jinja2.FileSystemLoader(searchpath=searchpath)
    env = jinja2.Environment(loader=loader)
    temp = env.get_template(template)

    return temp.render(**kwargs)
524099
public static Object formatL(final String template, final Object... args) {
    return new Object() {
      @Override
      public String toString() {
        return format(template, args);
      }
    };
  }
496108
function() {
    var template = this.model.get('template') ?
      this.model.get('template') :
      cdb.templates.getTemplate(this._getModelTemplate());

    if(typeof(template) !== 'function') {
      this.template = new cdb.core.Template({
        template: template,
        type: this.model.get('template_type') || 'mustache'
      }).asFunction()
    } else {
      this.template = template
    }

    this.render();
  }
408287
private static void renderFreemarkerTemplate(Path templatePath, Map vars, Path outputPath)
            throws IOException, TemplateException
    {
        if(templatePath == null)
            throw new WindupException("templatePath is null");

        freemarker.template.Configuration freemarkerConfig = new freemarker.template.Configuration(freemarker.template.Configuration.VERSION_2_3_26);
        DefaultObjectWrapperBuilder objectWrapperBuilder = new DefaultObjectWrapperBuilder(freemarker.template.Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
        objectWrapperBuilder.setUseAdaptersForContainers(true);
        objectWrapperBuilder.setIterableSupport(true);
        freemarkerConfig.setObjectWrapper(objectWrapperBuilder.build());
        freemarkerConfig.setTemplateLoader(new FurnaceFreeMarkerTemplateLoader());
        Template template = freemarkerConfig.getTemplate(templatePath.toString().replace('\\', '/'));
        try (FileWriter fw = new FileWriter(outputPath.toFile()))
        {
            template.process(vars, fw);
        }
    }
273619
function render_with_layout(template, locals, cb) {
    render_file(locals, function(err, str) {
      if (err) {
        return cb(err);
      }

      locals.body = str;

      var res = template(locals, handlebarsOpts);
      self.async.done(function(values) {
        Object.keys(values).forEach(function(id) {
          res = res.replace(id, values[id]);
        });

        cb(null, res);
      });
    });
  }
62927
public static HttpTemplate template(TemplateType type, String template) {
        return new HttpTemplate(type).withTemplate(template);
    }
795353
protected function fillTemplate($template, Model $model)
    {
        $template = str_replace('{{namespace}}', $model->getBaseNamespace(), $template);
        $template = str_replace('{{class}}', $model->getClassName(), $template);

        $properties = $this->properties($model);
        $usedClasses = $this->extractUsedClasses($properties);
        $template = str_replace('{{properties}}', $properties, $template);

        $parentClass = $model->getParentClass();
        $usedClasses = array_merge($usedClasses, $this->extractUsedClasses($parentClass));
        $template = str_replace('{{parent}}', $parentClass, $template);

        $body = $this->body($model);
        $usedClasses = array_merge($usedClasses, $this->extractUsedClasses($body));
        $template = str_replace('{{body}}', $body, $template);

        $usedClasses = array_unique($usedClasses);
        $usedClassesSection = $this->formatUsedClasses(
            $model->getBaseNamespace(),
            $usedClasses
        );
        $template = str_replace('{{imports}}', $usedClassesSection, $template);

        return $template;
    }
908347
def render_templates_generator(*files, **template_map):
    
    for path in files:
        if not os.path.isfile(path):
            raise ValueError("Template file %s not found"
                             % os.path.relpath(path))
        else:
            try:
                with codecs.open(path, encoding='utf-8') as f:
                    text = f.read()
                template = JINJA_ENV.from_string(text)
            except jinja2.TemplateSyntaxError as err:
                msg = ("Error rendering jinja2 template for file %s "
                       "on line %s. Error: %s"
                       % (path, err.lineno, err.message))
                raise type(err)(
                    msg, err.lineno, filename=os.path.basename(path))

            result = template.render(**template_map)
            if not result.endswith('\n'):
                result += '\n'
            yield path, result