Dropwizard :: Configuration :: Jtwig Templates

Treats the configuration file as a Jtwig template

License

License

Categories

Categories

DropWizard Container Microservices Configuration Application Layer Libs config
GroupId

GroupId

zone.dragon.dropwizard
ArtifactId

ArtifactId

dropwizard-configuration-jtwig
Last Version

Last Version

1.1.4-b6fb6b
Release Date

Release Date

Type

Type

jar
Description

Description

Dropwizard :: Configuration :: Jtwig Templates
Treats the configuration file as a Jtwig template
Project URL

Project URL

https://github.com/dragonzone/dropwizard-configuration-jtwig
Project Organization

Project Organization

DragonZone
Source Code Management

Source Code Management

https://github.com/dragonzone/dropwizard-configuration-jtwig/tree/master

Download dropwizard-configuration-jtwig

How to add to project

<!-- https://jarcasting.com/artifacts/zone.dragon.dropwizard/dropwizard-configuration-jtwig/ -->
<dependency>
    <groupId>zone.dragon.dropwizard</groupId>
    <artifactId>dropwizard-configuration-jtwig</artifactId>
    <version>1.1.4-b6fb6b</version>
</dependency>
// https://jarcasting.com/artifacts/zone.dragon.dropwizard/dropwizard-configuration-jtwig/
implementation 'zone.dragon.dropwizard:dropwizard-configuration-jtwig:1.1.4-b6fb6b'
// https://jarcasting.com/artifacts/zone.dragon.dropwizard/dropwizard-configuration-jtwig/
implementation ("zone.dragon.dropwizard:dropwizard-configuration-jtwig:1.1.4-b6fb6b")
'zone.dragon.dropwizard:dropwizard-configuration-jtwig:jar:1.1.4-b6fb6b'
<dependency org="zone.dragon.dropwizard" name="dropwizard-configuration-jtwig" rev="1.1.4-b6fb6b">
  <artifact name="dropwizard-configuration-jtwig" type="jar" />
</dependency>
@Grapes(
@Grab(group='zone.dragon.dropwizard', module='dropwizard-configuration-jtwig', version='1.1.4-b6fb6b')
)
libraryDependencies += "zone.dragon.dropwizard" % "dropwizard-configuration-jtwig" % "1.1.4-b6fb6b"
[zone.dragon.dropwizard/dropwizard-configuration-jtwig "1.1.4-b6fb6b"]

Dependencies

compile (5)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-core jar
io.dropwizard : dropwizard-configuration jar
io.dropwizard : dropwizard-core jar
org.jtwig : jtwig-core jar 5.86.1.RELEASE
org.slf4j : slf4j-api jar 1.7.25

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.20

test (3)

Group / Artifact Type Version
org.assertj : assertj-core jar 3.9.1
org.junit.jupiter : junit-jupiter-api jar 5.2.0
io.dropwizard : dropwizard-testing jar

Project Modules

There are no modules declared in this project.

Dropwizard Jtwig Templates Configuration Build Status Maven Central

This bundle enables jtwig template processing of an applications config.yaml file, making it easy to interpolate environmental variables, system properties, and other boot-time properties (such as passwords and secrets) into your application config, as well as making structural changes and alterations to the configuration based on settings such as the OS type or other environmental cues.

To use this bundle, add it to your application in the initialize method:

@Override
public void initialize(Bootstrap<YourConfig> bootstrap) {
    bootstrap.addBundle(new JtwigConfigurationBundle());
}

The initial data model contains all environmental variables under the env key, such as {{ env.PATH }} or {{ env.HOME }}, and all system properties under the system key, such as {{ system["user.dir"] }}

Escaping

By default, any strings will be escaped, so interpolations of strings should be double-quoted:

homeDir: "{{ env.HOME }}"

to insert an unescaped string, use the none format with the autoescape operator:

{% autoescape 'none' %}
homeDir: {{ env.HOME }}
{% endautoescape %}

Customizing Template Rendering

To customize the variables available inside the template, use one of the constructor overloads to pass in the desired model. This makes it easy to inject secrets or other startup properties into your configuration. For more advanced customizations, the EnvironmentConfiguration itself can be provided for use.

Note: When providing a custom data model or environment configuration, no defaults will be added; If you still want support for the environment variables, system properties, or YAML-compatible string escaping, you must make sure to include them in the inputs provided to the plugin.

zone.dragon.dropwizard

Versions

Version
1.1.4-b6fb6b
1.0.1-db2632