This project requires JVM version of at least 1.7
Templar templating engine
(Documentation now lives here: http://synapticloop.github.io/templar/)
A lightweight java templating engine - and by lightweight we mean a small number of lines of code... (that weights in around 90k):
No idea! - I guess the answer is 'fast-enough' depending on what you want to do with it.
We use it as the basis of our code generation tool h2zero
which has now
been open-sourced
Sometimes it matters, sometimes it doesn't - so by default we don't output tabs
and newlines unless explicitly asked to (i.e. {\\n}
or {\\t}
)
All whitespace is stripped from the beginning (yet NOT the end) of a line
should you wish to have whitespace at the start of the line, you will need to
use either the pre ({pre
) syntax or the escape ({\\
) syntax.
You may change this behaviour by creating a TemplarConfiguration
object and
setting it in the templar context object.
TemplarConfiguration templarConfiguration = new TemplarConfiguration();
templarConfiguration.setExplicitNewLines(false);
templarConfiguration.setExplicitTabs(false)
TemplarContext templarContext = new TemplarContext(templarConfiguration);
The file quick-convert.html
at the root of the project is an all-in-one html
file which will allow you to convert your existing text into templar formatted
text.
From the root of the project, simply run
./gradlew build
./gradlew.bat build
This will compile and assemble the artefacts into the build/libs/
directory.
Note that this may also run tests (if applicable see the Testing notes)
slf4j is the logging framework used for this project. In order to set up a logging framework with this project, sample configurations are below:
You will need to include dependencies for this - note that the versions may need to be updated.
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
<scope>runtime</scope>
</dependency>
dependencies {
...
runtime(group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.5', ext: 'jar')
runtime(group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5', ext: 'jar')
...
}
dependencies {
...
runtime 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
runtime 'org.apache.logging.log4j:log4j-core:2.5'
...
}
A sample log4j2.xml
is below:
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
This project publishes artefacts to GitHub
Note that the latest version can be found https://github.com/synapticloop/templar/releases
As such, this is not a repository, but a location to download files from.
This project publishes artefacts to bintray
Note that the latest version can be found https://bintray.com/synapticloop/maven/templar/view
this comes from the jcenter bintray, to set up your repository:
<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd' xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<id>bintray</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>bintray</activeProfile>
</activeProfiles>
</settings>
Repository
repositories {
maven {
url "http://jcenter.bintray.com"
}
}
or just
repositories {
jcenter()
}
dependencies {
runtime(group: 'synapticloop', name: 'templar', version: '1.4.3', ext: 'jar')
compile(group: 'synapticloop', name: 'templar', version: '1.4.3', ext: 'jar')
}
or, more simply for versions of gradle greater than 2.1
dependencies {
runtime 'synapticloop:templar:1.4.3'
compile 'synapticloop:templar:1.4.3'
}
<dependency>
<groupId>synapticloop</groupId>
<artifactId>templar</artifactId>
<version>1.4.3</version>
<type>jar</type>
</dependency>
You will also need to download the following dependencies:
net.sourceforge.cobertura:cobertura:2.0.3
: (It may be available on one of: bintray mvn central)
org.json:json:20160212
: (It may be available on one of: bintray mvn central)
org.json:json:20160212
: (It may be available on one of: bintray mvn central)
junit:junit:4.11
: (It may be available on one of: bintray mvn central)org.mockito:mockito-all:1.10.19
: (It may be available on one of: bintray mvn central)
junit:junit:4.11
: (It may be available on one of: bintray mvn central)org.mockito:mockito-all:1.10.19
: (It may be available on one of: bintray mvn central)
NOTE: You may need to download any dependencies of the above dependencies in turn (i.e. the transitive dependencies)
The MIT License (MIT)
Copyright (c) 2017 synapticloop
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--
This README.md file was hand-crafted with care utilising synapticloop
templar
->
documentr
--