java类freemarker.template.Version的实例源码

FreeMarkerProcessor.java 文件源码 项目:community-edition-old 阅读 20 收藏 0 点赞 0 评论 0
/**
 * FreeMarker configuration for loading the specified template directly from a String
 * 
 * @param path      Pseudo Path to the template
 * @param template  Template content
 * 
 * @return FreeMarker configuration
 */
protected Configuration getStringConfig(String path, String template)
{
    Configuration config = new Configuration();

    // setup template cache
    config.setCacheStorage(new MruCacheStorage(2, 0));

    // use our custom loader to load a template directly from a String
    StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
    stringTemplateLoader.putTemplate(path, template);
    config.setTemplateLoader(stringTemplateLoader);

    // use our custom object wrapper that can deal with QNameMap objects directly
    config.setObjectWrapper(qnameObjectWrapper);

    // rethrow any exception so we can deal with them
    config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

    // set default template encoding
    if (defaultEncoding != null)
    {
        config.setDefaultEncoding(defaultEncoding);
    }
    config.setIncompatibleImprovements(new Version(2, 3, 20));
    config.setNewBuiltinClassResolver(TemplateClassResolver.SAFER_RESOLVER);

    return config;
}
Engine.java 文件源码 项目:easydao 阅读 22 收藏 0 点赞 0 评论 0
/**
 * @see http://freemarker.org/docs/pgui_quickstart_createconfiguration.html
 * @return Freemarker configuration
 */
private void initFreemarkerConfiguration() {
    freemarkerConfig = new Configuration();
    freemarkerConfig.setClassForTemplateLoading(Engine.class, "/hu/vanio/easydao/templates");
    freemarkerConfig.setObjectWrapper(new DefaultObjectWrapper());
    freemarkerConfig.setDefaultEncoding("UTF-8");
    freemarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    freemarkerConfig.setIncompatibleImprovements(new Version(2, 3, 23));
}
StaticPageUtil.java 文件源码 项目:deeplearning4j 阅读 19 收藏 0 点赞 0 评论 0
public static String renderHTMLContent(Component... components) throws Exception {

        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
        mapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);
        mapper.enable(SerializationFeature.INDENT_OUTPUT);

        Configuration cfg = new Configuration(new Version(2, 3, 23));

        // Where do we load the templates from:
        cfg.setClassForTemplateLoading(StaticPageUtil.class, "");

        // Some other recommended settings:
        cfg.setIncompatibleImprovements(new Version(2, 3, 23));
        cfg.setDefaultEncoding("UTF-8");
        cfg.setLocale(Locale.US);
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

        ClassPathResource cpr = new ClassPathResource("assets/dl4j-ui.js");
        String scriptContents = IOUtils.toString(cpr.getInputStream(), "UTF-8");

        Map<String, Object> pageElements = new HashMap<>();
        List<ComponentObject> list = new ArrayList<>();
        int i = 0;
        for (Component c : components) {
            list.add(new ComponentObject(String.valueOf(i), mapper.writeValueAsString(c)));
            i++;
        }
        pageElements.put("components", list);
        pageElements.put("scriptcontent", scriptContents);


        Template template = cfg.getTemplate("staticpage.ftl");
        Writer stringWriter = new StringWriter();
        template.process(pageElements, stringWriter);

        return stringWriter.toString();
    }
HTMLGameBrowser.java 文件源码 项目:chesspresso 阅读 19 收藏 0 点赞 0 评论 0
private Configuration makeConfiguration(boolean debugMode) {
  final Configuration config = new Configuration();

  config.setIncompatibleImprovements(new Version(2, 3, 20));
  config.setClassForTemplateLoading(HTMLGameBrowser.class, "freemarker");
  config.setDefaultEncoding("UTF-8");

  if (debugMode) {
    config.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);
  } else {
    config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
  }

  return config;
}
RestServlet.java 文件源码 项目:restlight 阅读 21 收藏 0 点赞 0 评论 0
private void initTemplateEngine(ServletConfig config) throws ServletException {

        cfg = new Configuration();

        // Specify the data source where the template files come from. Here I
        // set a
        // plain directory for it, but non-file-system are possible too:
        cfg.setServletContextForTemplateLoading(config.getServletContext(), "/");

        // Specify how templates will see the data-model. This is an advanced
        // topic...
        // for now just use this:
        cfg.setObjectWrapper(new DefaultObjectWrapper());

        // Set your preferred charset template files are stored in. UTF-8 is
        // a good choice in most applications:
        cfg.setDefaultEncoding("UTF-8");

        // Sets how errors will appear. Here we assume we are developing HTML
        // pages.
        // For production systems TemplateExceptionHandler.RETHROW_HANDLER is
        // better.
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.HTML_DEBUG_HANDLER);

        // At least in new projects, specify that you want the fixes that aren't
        // 100% backward compatible too (these are very low-risk changes as far
        // as the
        // 1st and 2nd version number remains):
        cfg.setIncompatibleImprovements(new Version(2, 3, 20)); // FreeMarker
                                                                // 2.3.20
    }
ScipioFtlWrappers.java 文件源码 项目:scipio-erp 阅读 22 收藏 0 点赞 0 评论 0
public ScipioBasicBeansWrapperImpl(Version incompatibleImprovements, Collection<? extends ScipioModelFactory> customWrapperFactories) {
    super(incompatibleImprovements);
    this.customWrapperFactories = makeCleanFactoryList(customWrapperFactories);
}
ScipioFtlWrappers.java 文件源码 项目:scipio-erp 阅读 20 收藏 0 点赞 0 评论 0
public static ScipioBasicBeansWrapperImpl create(Version incompatibleImprovements) {
    return new ScipioBasicBeansWrapperImpl(incompatibleImprovements, systemWrapperFactories);
}
ScipioFtlWrappers.java 文件源码 项目:scipio-erp 阅读 23 收藏 0 点赞 0 评论 0
public ScipioBasicDefaultObjectWrapperImpl(Version incompatibleImprovements, Collection<? extends ScipioModelFactory> customWrapperFactories) {
    super(incompatibleImprovements);
    this.customWrapperFactories = makeCleanFactoryList(customWrapperFactories);
}
ScipioFtlWrappers.java 文件源码 项目:scipio-erp 阅读 17 收藏 0 点赞 0 评论 0
public static ScipioBasicDefaultObjectWrapperImpl create(Version incompatibleImprovements) {
    return new ScipioBasicDefaultObjectWrapperImpl(incompatibleImprovements, systemWrapperFactories);
}
ScipioFtlWrappers.java 文件源码 项目:scipio-erp 阅读 19 收藏 0 点赞 0 评论 0
public ScipioExtendedBeansWrapperImpl(Version incompatibleImprovements, Collection<? extends ScipioModelFactory> customWrapperFactories, String encodeLang) {
    super(incompatibleImprovements);
    this.customWrapperFactories = makeCleanFactoryList(customWrapperFactories);
    this.encodeLang = encodeLang;
    this.encoder = UtilCodec.getEncoder(this.encodeLang);
}


问题


面经


文章

微信
公众号

扫码关注公众号