Package org.thymeleaf

Examples of org.thymeleaf.TemplateEngine


    } catch (IOException e) {
      throw new ConfigurationException("Can not load property file " + propFileName, e);
    }

    {
      myProfileTemplateEngine = new TemplateEngine();
      TemplateResolver resolver = new TemplateResolver();
      resolver.setResourceResolver(new ProfileResourceResolver());
      myProfileTemplateEngine.setTemplateResolver(resolver);
      StandardDialect dialect = new StandardDialect();
      HashSet<IProcessor> additionalProcessors = new HashSet<IProcessor>();
      additionalProcessors.add(new NarrativeAttributeProcessor());
      dialect.setAdditionalProcessors(additionalProcessors);
      myProfileTemplateEngine.setDialect(dialect);
      myProfileTemplateEngine.initialize();
    }
    {
      myTitleTemplateEngine = new TemplateEngine();
      TemplateResolver resolver = new TemplateResolver();
      resolver.setResourceResolver(new TitleResourceResolver());
      myTitleTemplateEngine.setTemplateResolver(resolver);
      StandardDialect dialect = new StandardDialect();
      HashSet<IProcessor> additionalProcessors = new HashSet<IProcessor>();
View Full Code Here


    private void initializeTemplateEngine() {
        templateResolver = new FileTemplateResolver();
        templateResolver.setPrefix(templatesPath.getAbsolutePath() + File.separatorChar);
        templateResolver.setCharacterEncoding(config.getString(Keys.TEMPLATE_ENCODING));
        templateEngine = new TemplateEngine();
        templateEngine.setTemplateResolver(templateResolver);
    }
View Full Code Here

    } catch (IOException e) {
      throw new ConfigurationException("Can not load property file " + propFileName, e);
    }

    {
      myProfileTemplateEngine = new TemplateEngine();
      TemplateResolver resolver = new TemplateResolver();
      resolver.setResourceResolver(new ProfileResourceResolver());
      myProfileTemplateEngine.setTemplateResolver(resolver);
      StandardDialect dialect = new StandardDialect();
      HashSet<IProcessor> additionalProcessors = new HashSet<IProcessor>();
      additionalProcessors.add(new NarrativeAttributeProcessor());
      dialect.setAdditionalProcessors(additionalProcessors);
      myProfileTemplateEngine.setDialect(dialect);
      myProfileTemplateEngine.initialize();
    }
    {
      myTitleTemplateEngine = new TemplateEngine();
      TemplateResolver resolver = new TemplateResolver();
      resolver.setResourceResolver(new TitleResourceResolver());
      myTitleTemplateEngine.setTemplateResolver(resolver);
      StandardDialect dialect = new StandardDialect();
      HashSet<IProcessor> additionalProcessors = new HashSet<IProcessor>();
View Full Code Here

    return myCtx;
  }

  @Override
  public void init(ServletConfig theConfig) throws ServletException {
    myTemplateEngine = new TemplateEngine();
    TemplateResolver resolver = new TemplateResolver();
    resolver.setResourceResolver(new ProfileResourceResolver());
    myTemplateEngine.setTemplateResolver(resolver);
    StandardDialect dialect = new StandardDialect();
    myTemplateEngine.setDialect(dialect);
View Full Code Here

    } catch (IOException e) {
      throw new ConfigurationException("Can not load property file " + propFileName, e);
    }

    {
      myProfileTemplateEngine = new TemplateEngine();
      TemplateResolver resolver = new TemplateResolver();
      resolver.setResourceResolver(new ProfileResourceResolver());
      myProfileTemplateEngine.setTemplateResolver(resolver);
      StandardDialect dialect = new StandardDialect();
      HashSet<IProcessor> additionalProcessors = new HashSet<IProcessor>();
View Full Code Here

    } catch (IOException e) {
      throw new ConfigurationException("Can not load property file " + propFileName, e);
    }

    {
      myProfileTemplateEngine = new TemplateEngine();
      TemplateResolver resolver = new TemplateResolver();
      resolver.setResourceResolver(new ProfileResourceResolver());
      myProfileTemplateEngine.setTemplateResolver(resolver);
      StandardDialect dialect = new StandardDialect();
      HashSet<IProcessor> additionalProcessors = new HashSet<IProcessor>();
View Full Code Here

    EnvironmentTestUtils.addEnvironment(this.context, "spring.thymeleaf.mode:XHTML",
        "spring.thymeleaf.suffix:");
    this.context.register(ThymeleafAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    TemplateEngine engine = this.context.getBean(TemplateEngine.class);
    Context attrs = new Context(Locale.UK, Collections.singletonMap("foo", "bar"));
    String result = engine.process("template.txt", attrs);
    assertEquals("<html>bar</html>", result);
  }
View Full Code Here

  @Test
  public void useDataDialect() throws Exception {
    this.context.register(ThymeleafAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    TemplateEngine engine = this.context.getBean(TemplateEngine.class);
    Context attrs = new Context(Locale.UK, Collections.singletonMap("foo", "bar"));
    String result = engine.process("data-dialect", attrs);
    assertEquals("<html><body data-foo=\"bar\"></body></html>", result);
  }
View Full Code Here

  @Test
  public void renderTemplate() throws Exception {
    this.context.register(ThymeleafAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    this.context.refresh();
    TemplateEngine engine = this.context.getBean(TemplateEngine.class);
    Context attrs = new Context(Locale.UK, Collections.singletonMap("foo", "bar"));
    String result = engine.process("home", attrs);
    assertEquals("<html><body>bar</body></html>", result);
  }
View Full Code Here

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
        ThymeleafAutoConfiguration.class,
        PropertyPlaceholderAutoConfiguration.class);
    assertEquals(0, context.getBeanNamesForType(ViewResolver.class).length);
    try {
      TemplateEngine engine = context.getBean(TemplateEngine.class);
      Context attrs = new Context(Locale.UK, Collections.singletonMap("greeting",
          "Hello World"));
      String result = engine.process("message", attrs);
      assertThat(result, containsString("Hello World"));
    }
    finally {
      context.close();
    }
View Full Code Here

TOP

Related Classes of org.thymeleaf.TemplateEngine

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.