Spaceless Extension

The spaceless extension is a tiny extension which add the spaceless tag construct to Jtwig. It works with HTML by default, allowing one to remove unnecessary whitespaces.

{% spaceless %}
<div>
    <label>Example</label>
</div>
{% endspaceless %}

The previous example will produce <div><label>Example</label>

Configuration

EnvironmentConfigurationBuilder.configuration()
    .extensions()
        .add(SpacelessExtension.defaultSpacelessExtension())
    .and()
.build()

The previous example will plugin the Spaceless extension with the default configuration. The only parameter to be configured is an instance of SpaceRemover which is used to remove the whitespaces from the content. By default this extension is configured to use the HtmlSpaceRemover implementation.

Integration

Integrating Jtwig Spaceless Extension on your project is quite simple with the help of dependency managers. To check the most recent version, go to bintray.

Gradle

repositories {
    jcenter()
}
dependencies {
    compile 'org.jtwig:jtwig-spaceless-extension:1.X'
}

Maven

<repositories>
    <repository>
        <id>bintray</id>
        <url>https://jcenter.bintray.com/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.jtwig</groupId>
        <artifactId>jtwig-spaceless-extension</artifactId>
        <version>1.X</version>
    </dependency>
</dependencies>

Examples

Check the jtwig-examples project on github for examples using this spaceless engine.