Interface TypeSafeTemplate<T>

Type Parameters:
T - The root object type.

@Deprecated(since="2024-07-10") public interface TypeSafeTemplate<T>
Deprecated.
com.github.jknack.handlebars package is deprecated and marked for removal in subsequent releases which will involve removal of the handlebars dependency in AEM.
Make handlebars templates type-safe. Users can extend the TypeSafeTemplate and add new methods.

Usage:

   public interface UserTemplate extends TypeSafeTemplate<User> {
     UserTemplate setAge(int age);

     UserTemplate setRole(String role);

     ...
   }

   UserTemplate template = new Handlebars().compileInline("{{name}} is {{age}} years old!")
     .as(UserTemplate.class);

   template.setAge(32);

   assertEquals("Edgar is 32 years old!", template.apply(new User("Edgar")));
  
Since:
0.10.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(T context)
    Deprecated.
    Merge the template tree using the given context.
    void
    apply(T context, Writer writer)
    Deprecated.
    Merge the template tree using the given context.
  • Method Details

    • apply

      void apply(T context, Writer writer) throws IOException
      Deprecated.
      Merge the template tree using the given context.
      Parameters:
      context - The context object. May be null.
      writer - The writer object. Required.
      Throws:
      IOException - If a resource cannot be loaded.
    • apply

      String apply(T context) throws IOException
      Deprecated.
      Merge the template tree using the given context.
      Parameters:
      context - The context object. May be null.
      Returns:
      The resulting template.
      Throws:
      IOException - If a resource cannot be loaded.