Package freemarker.cache

Examples of freemarker.cache.ClassTemplateLoader


                // Create different loaders.
                final List<TemplateLoader> loaders = Lists.newArrayList();
                if (servletContext != null) {
                    loaders.add(new WebappTemplateLoader(servletContext));
                }
                loaders.add(new ClassTemplateLoader(FreemarkerViewProcessor.class, "/"));
                try {
                    loaders.add(new FileTemplateLoader(new File("/")));
                } catch (IOException e) {
                    // NOOP
                }
View Full Code Here


        TemplateLoader templatePathLoader = null;

        try {
             if (templatePath.startsWith("class://")) {
                 // substring(7) is intentional as we "reuse" the last slash
                 templatePathLoader = new ClassTemplateLoader(getClass(), templatePath.substring(7));
             } else if (templatePath.startsWith("file://")) {
                 templatePathLoader = new FileTemplateLoader(new File(URI.create(templatePath)));
             }
         } catch (IOException e) {
             LOG.error("Invalid template path specified: " + e.getMessage(), e);
View Full Code Here

         try {
             if(templatePath!=null){
                 if (templatePath.startsWith("class://")) {
                     // substring(7) is intentional as we "reuse" the last slash
                     templatePathLoader = new ClassTemplateLoader(getClass(), templatePath.substring(7));
                 } else if (templatePath.startsWith("file://")) {
                     templatePathLoader = new FileTemplateLoader(new File(templatePath.substring(7)));
                 }
             }
         } catch (IOException e) {
View Full Code Here

   * This implementation registers an additional ClassTemplateLoader
   * for the Spring-provided macros, added to the end of the list.
   */
  @Override
  protected void postProcessTemplateLoaders(List<TemplateLoader> templateLoaders) {
    templateLoaders.add(new ClassTemplateLoader(FreeMarkerConfigurer.class, ""));
    logger.info("ClassTemplateLoader for Spring macros added to FreeMarker configuration");
  }
View Full Code Here

     *
     * @param servletContext The servlet context.
     */
    public WebappClassTemplateLoader(ServletContext servletContext) {
        webappTemplateLoader = new WebappTemplateLoader(servletContext);
        classTemplateLoader = new ClassTemplateLoader(getClass(), "/");
    }
View Full Code Here

            try {
                // the src dir of user's project.
                FileTemplateLoader fileTemplateLoader = new FileTemplateLoader(new File(srcDir));
                // then ftl.html files from the classpath (eg. from inherited modules
                // or the ninja core module)
                ClassTemplateLoader classTemplateLoader = new ClassTemplateLoader(this.getClass(), "/");
               
                TemplateLoader [] templateLoader = new TemplateLoader[] {
                        fileTemplateLoader,
                        classTemplateLoader };
               
View Full Code Here

     */
    protected TemplateLoader createTemplateLoader(String templatePath) throws IOException
    {
        if (templatePath.startsWith("class://")) {
            // substring(7) is intentional as we "reuse" the last slash
            return new ClassTemplateLoader(getClass(), templatePath.substring(7));
        } else {
            if (templatePath.startsWith("file://")) {
                templatePath = templatePath.substring(7);
                return new FileTemplateLoader(new File(templatePath));
            } else {
View Full Code Here

    /**
     * Sets a class relative to which we do the
     * Class.getResource() call to load templates.
     */
    public void setClassForTemplateLoading(Class clazz, String pathPrefix) {
        setTemplateLoaderNoCheck(new ClassTemplateLoader(clazz, pathPrefix));
    }
View Full Code Here

        final TypeElement element = env.getElementUtils().getTypeElement(Entity.class.getName());
        if (annotations.contains(element)) {
            try {
                Configuration cfg = new Configuration();
                cfg.setObjectWrapper(new DefaultObjectWrapper());
                cfg.setTemplateLoader(new ClassTemplateLoader(getClass(), "/templates"));
                Template template = cfg.getTemplate("criteria.ftl");
                for (TypeElement typeElement : ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(Entity.class))) {
                    generate(template, typeElement);
                }
                template = cfg.getTemplate("embedded.ftl");
View Full Code Here

    FileTemplateLoader fileTemplateLoader = createFileTemplateLoader(templateDirectory);
    this.configuration.setTemplateLoader(
        new MultiTemplateLoader(new TemplateLoader[]{
            fileTemplateLoader,
            new ClassTemplateLoader(getClass(), "/"),
        }));
  }
View Full Code Here

TOP

Related Classes of freemarker.cache.ClassTemplateLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.