包装Thymeleaf模板

@param engine Thymeleaf的模板引擎对象 {@link TemplateEngine}
@param template 模板路径或模板内容
@param charset 编码
@return {@link ThymeleafTemplate}
503098
public static ThymeleafTemplate wrap(TemplateEngine engine, String template, Charset charset) {
		return (null == engine) ? null : new ThymeleafTemplate(engine, template, charset);
	}
458271
public static StringTemplate stringTemplate(String template, Object... args) {
        return stringTemplate(createTemplate(template), ImmutableList.copyOf(args));
    }
407118
def get_template(template_name, using=None):
    
    engines = _engine_list(using)
    for engine in engines:
        try:
            return engine.get_template(template_name)
        except TemplateDoesNotExist as e:
            pass

    raise TemplateDoesNotExist(template_name)
1019458
public static <T> DslTemplate<T> dslTemplate(Class<? extends T> cl, String template, List<?> args) {
        return dslTemplate(cl, createTemplate(template), args);
    }
505704
public static TemplateViewRouteImpl create(String path,
                                               TemplateViewRoute route,
                                               TemplateEngine engine) {

        return create(path, Service.DEFAULT_ACCEPT_TYPE, route, engine);
    }
384408
public static String renderStr(String template, Object... args) {
        return engine().renderString(template, args);
    }
1245529
private static com.jfinal.template.Engine createEngine(TemplateConfig config) {
		Assert.notNull(config, "Template config is null !");
		final com.jfinal.template.Engine engine = com.jfinal.template.Engine.create("Hutool-Enjoy-Engine-" + config.toString());
		engine.setEncoding(config.getCharsetStr());

		switch (config.getResourceMode()) {
		case STRING:
			// 默认字符串类型资源:
			break;
		case CLASSPATH:
			engine.setToClassPathSourceFactory();
			engine.setBaseTemplatePath(config.getPath());
			break;
		case FILE:
			engine.setSourceFactory(new FileSourceFactory());
			engine.setBaseTemplatePath(config.getPath());
			break;
		case WEB_ROOT:
			engine.setSourceFactory(new FileSourceFactory());
			engine.setBaseTemplatePath(FileUtil.getAbsolutePath(FileUtil.getWebRoot()));
			break;
		default:
			break;
		}

		return engine;
	}
961973
public static VelocityEngine newEngine(String templateDir, String charset) {
		final VelocityEngine ve = new VelocityEngine();

		ve.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, true); // 使用缓存
		ve.init(_newInitedProp(templateDir, charset));

		return ve;
	}
427705
public String render(String template) {
    ENGINE_LOG.debug(template);
    return render(parse(template), true);
  }
58404
private Template getTemplate(String templateName) throws ParseException {
    try {
      return config.getTemplate(templateName, "UTF-8");
    } catch (ParseException e) {
      throw e;
    } catch (IOException e) {
      logger.error("Couldn't load template '{}',loader is {}", templateName,
          config.getTemplateLoader().getClass());
      throw Throwables.propagate(e);
    }
  }
923775
function (scanner, quote) {
  if (quote) {
    if (scanner.peek() !== quote)
      return null;
    scanner.pos++;
  }

  var tokens = [];
  var charsTokenToExtend = null;

  var charRef;
  while (true) {
    var ch = scanner.peek();
    var templateTag;
    var curPos = scanner.pos;
    if (quote && ch === quote) {
      scanner.pos++;
      return tokens;
    } else if ((! quote) && (HTML_SPACE.test(ch) || ch === '>')) {
      return tokens;
    } else if (! ch) {
      scanner.fatal("Unclosed attribute in tag");
    } else if (quote ? ch === '\u0000' : ('\u0000"\'<=`'.indexOf(ch) >= 0)) {
      scanner.fatal("Unexpected character in attribute value");
    } else if (ch === '&' &&
               (charRef = getCharacterReference(scanner, true,
                                                quote || '>'))) {
      tokens.push(charRef);
      charsTokenToExtend = null;
    } else if (scanner.getTemplateTag &&
               ((templateTag = scanner.getTemplateTag(
                 scanner, TEMPLATE_TAG_POSITION.IN_ATTRIBUTE)) ||
                scanner.pos > curPos /* `{{! comment}}` */)) {
      if (templateTag) {
        tokens.push({t: 'TemplateTag',
                     v: assertIsTemplateTag(templateTag)});
        charsTokenToExtend = null;
      }
    } else {
      if (! charsTokenToExtend) {
        charsTokenToExtend = { t: 'Chars', v: '' };
        tokens.push(charsTokenToExtend);
      }
      charsTokenToExtend.v += (ch === '\r' ? '\n' : ch);
      scanner.pos++;
      if (quote && ch === '\r' && scanner.peek() === '\n')
        scanner.pos++;
    }
  }
}
414904
@Override
	public Template getTemplate(String resource) {
		return RythmTemplate.wrap(engine.getTemplate(resource));
	}
262268
@Override
    public ITemplate __cloneMe(RythmEngine engine, ITemplate caller) {
        if (null == engine) throw new NullPointerException();
        TemplateBase tmpl = __internalClone();
        if (tmpl.__parent != null) {
            tmpl.__parent = (TemplateBase) tmpl.__parent.__cloneMe(engine, caller);
        }
        tmpl.__engine = engine;
        //tmpl.__templateClass = __templateClass;
        tmpl.__ctx = new __Context();
        //if (null != buffer) tmpl.__buffer = buffer;
        if (null != __buffer) tmpl.__buffer = new StringBuilder();
        tmpl.__renderArgs = new HashMap<String, Object>(__renderArgs.size());
        //tmpl.layoutContent = "";
        tmpl.layoutSections = new HashMap<String, String>();
        tmpl.layoutSections0 = new HashMap<String, String>();
        tmpl.renderProperties = new HashMap<String, Object>();
        //tmpl.section = null;
        //tmpl.tmpCaller = null;
        //tmpl.tmpOut = null;
        //tmpl.__logTime = __logTime;
        //tmpl.w = null;
        //tmpl.os = null;
        if (null != caller) {
            tmpl.__caller = (TextBuilder) caller;
            Map<String, Object> callerRenderArgs = new HashMap<String, Object>(((TemplateBase) caller).__renderArgs);
            Map<String, Class> types = tmpl.__renderArgTypeMap();
            for (Map.Entry<String, Object> entry : callerRenderArgs.entrySet()) {
                if (tmpl.__renderArgs.containsKey(entry.getKey())) continue;
                Object o = entry.getValue();
                if (null == o || __isDefVal(o)) continue;
                Class<?> c = types.get(entry.getKey());

                if (null == c || c.isAssignableFrom(o.getClass())) {
                    tmpl.__setRenderArg(entry.getKey(), o);
                }
            }
        }
        tmpl.__setUserContext(engine.renderSettings.userContext());
        return tmpl;
    }
538596
public static <T> TemplateExpression<T> template(Class<? extends T> cl, String template, List<?> args) {
        return template(cl, TemplateFactory.DEFAULT.create(template), args);
    }
1316284
public int writeTemplate(String template, ValueSet vs) {
        int returnCode = htod.writeTemplate(template, vs);
        if (returnCode == HTODDynacache.DISK_EXCEPTION) {
            stopOnError(this.htod.diskCacheException);
        }
        return returnCode;
    }
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);
    }
394486
private void mapEngine(Map<String, Provider<? extends TemplateEngine>> map, Provider<? extends TemplateEngine> engine) {
        for (String type : engine.get().getContentType()) {
            map.put(type, engine);
        }
    }