-
Notifications
You must be signed in to change notification settings - Fork 0
Introduction
Trimness is:
- an open source project licensed under the Apache License 2.0
- a GitHub repository available at https://github.com/trimou/trimness
- a practical and extensible tool to build a lightweight service to render templates
Trimness is NOT:
- a silver bullet framework/library
- an application server nor a deployable application
It is good e.g. to:
- build a simple reporting application
- build a rendering component in a microservice architecture
It is built on several open source projects:
- Trimou (mustache/handlebars-like templating engine)
- Weld (CDI component model, extensibility)
- Vert.x (web server, routing, event bus)
In a nutshell: the business of Trimness is to render templates using a clear API. So far there are two ways to send a "render request" to Trimness:
- HTTP endpoints
- Vert.x event bus
The best way to start with Trimness is to play with the simple example. Clone the repository, build the project and run the example shaded jar:
$ git clone git@github.com:trimou/trimness.git
$ cd trimness
$ mvn clean install
$ java -jar examples/simple/target/trimness-example-simple-shaded.jarFirst, let's make sure Trimness is up and running (using HTTP GET):
$ curl localhost:8080/monitor/healthYou should get something like:
{"checks":[{"id":"org.trimou.trimness.TrimouEngine","result":"success"}],"result":"success"}Now, let's use curl to perform a very simple hello world render request (using HTTP POST):
$ curl -X POST -H "Content-Type: application/json" -d '{ "templateContent" : "Hello {{model.name}}!", "model" : { "name" : "Foo"} }' http://localhost:8080/renderThe reply should be Hello Foo!.
See also the project README for HTTP endpoints details.
There is also a simple test HTML form located at localhost:8080/test.
Try this if you prefer UI over command line.
E.g. insert commits-list.html in the template id field and hit render button.
You should get a link to a result - HTML page with list of last commits from the Trimness repository.
Note that this example shows one of the extension points - ModelProvider - in action.
GithubModelProvider makes use of GitHub API to fetch the data for the template.
Trimness defines several extension points which allow you to enrich the built-in functionality.
Since the component model is built on CDI adding a new feature usually involves adding a new bean class which follows an extension point contract (e.g. ModelProvider) on the classpath.
The extension points API is almost finished.
Now we'd like to add some optional modules that will provide additional functionality.
Feel free to stop by and file a new issue/feature request in https://github.com/trimou/trimness/issues.