Package org.thymeleaf.context

Examples of org.thymeleaf.context.Context


        throw new DataFormatException("No narrative template for class " + theResource.getClass().getCanonicalName());
      }
    }

    try {
      Context context = new Context();
      context.setVariable("resource", theResource);
     
      String result = myProfileTemplateEngine.process(name, context);

      if (myCleanWhitespace) {
        ourLog.trace("Pre-whitespace cleaning: ", result);
View Full Code Here



      theElement.removeAttribute(theAttributeName);
      theElement.clearChildren();

      Context context = new Context();
      context.setVariable("resource", value);
     
      String name = myClassToNarrativeName.get(value.getClass());
      if (name == null) {
        if (myIgnoreMissingTemplates) {
          ourLog.debug("No narrative template available for type: {}", value.getClass());
View Full Code Here

        "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

  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

  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

        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 {
View Full Code Here

        throw new DataFormatException("No narrative template for class " + theResource.getClass().getCanonicalName());
      }
    }

    try {
      Context context = new Context();
      context.setVariable("resource", theResource);

      String result = myProfileTemplateEngine.process(name, context);

      if (myCleanWhitespace) {
        ourLog.trace("Pre-whitespace cleaning: ", result);
View Full Code Here

        throw new DataFormatException("No title template for class " + theResource.getClass().getCanonicalName());
      }
    }

    try {
      Context context = new Context();
      context.setVariable("resource", theResource);

      String result = myTitleTemplateEngine.process(name, context);

      ourLog.trace("Produced {}", result);
View Full Code Here

      if (value == null) {
        return ProcessorResult.ok();
      }

      Context context = new Context();
      context.setVariable("resource", value);

      String name = null;
      if (value != null) {
        Class<? extends Object> nextClass = value.getClass();
        do {
View Full Code Here

    modelBuilder.accept(builder);
    return thymeleafTemplate(builder.build(), name, contentType);
  }

  public static Template thymeleafTemplate(Map<String, ?> model, String name, String contentType) {
    Context context = new Context();
    if (model != null) {
      context.setVariables(model);
    }

    return new Template(name, context, contentType);
  }
View Full Code Here

TOP

Related Classes of org.thymeleaf.context.Context

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.