Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Introduction

Martin Kouba edited this page Jul 13, 2017 · 3 revisions

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:

  1. HTTP endpoints
  2. Vert.x event bus

Get started with HTTP endpoints

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.jar

First, let's make sure Trimness is up and running (using HTTP GET):

$ curl localhost:8080/monitor/health

You 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/render

The 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.

Future and plans

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.

Clone this wiki locally