Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Files

Latest commit

 

History

History
59 lines (45 loc) · 1.27 KB

README.md

File metadata and controls

59 lines (45 loc) · 1.27 KB

spark-template-httl

Maven dependency:

<dependency>
    <groupId>com.github.azazar</groupId>
    <artifactId>spark-template-httl</artifactId>
    <version>2.8.0</version>
</dependency>

How to use the Httl template route for Spark example:

import static spark.Spark.get;

import java.util.HashMap;
import java.util.Map;

import spark.Request;
import spark.Response;
import spark.template.httl.HttlTemplateEngine;

/**
 * HttlTemplateRoute example.
 */
public final class HttlExample {
    
    public static void main(final String[] args) {

        get("/hello", (request, response) -> {
            Map<String, Object> model = new HashMap<>();
            model.put("hello", "Httl World");
            model.put("person", new Person("Foobar"));

            // The vm files are located under the resources directory
            return new ModelAndView(model, "hello.httl");
        }, new HttlTemplateEngine());

    }

    public static class Person {
        private String name;

        public Person(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
    }
}