Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dgroup/laconic-velocity
Laconic API for Apache Velocity
https://github.com/dgroup/laconic-velocity
apache-velocity elegantobjects java java-library oop oop-library oop-principles velocity-template
Last synced: 3 months ago
JSON representation
Laconic API for Apache Velocity
- Host: GitHub
- URL: https://github.com/dgroup/laconic-velocity
- Owner: dgroup
- License: mit
- Created: 2018-09-28T16:17:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-10T16:40:30.000Z (almost 3 years ago)
- Last Synced: 2024-10-10T17:22:26.244Z (3 months ago)
- Topics: apache-velocity, elegantobjects, java, java-library, oop, oop-library, oop-principles, velocity-template
- Language: Java
- Homepage:
- Size: 86.9 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 9
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
[![Maven](https://img.shields.io/maven-central/v/com.github.dgroup/laconic-velocity.svg)](https://mvnrepository.com/artifact/com.github.dgroup/laconic-velocity)
[![Javadocs](http://www.javadoc.io/badge/com.github.dgroup/laconic-velocity.svg)](http://www.javadoc.io/doc/com.github.dgroup/laconic-velocity)
[![License: MIT](https://img.shields.io/github/license/mashape/apistatus.svg)](./license.txt)
[![Commit activity](https://img.shields.io/github/commit-activity/y/dgroup/laconic-velocity.svg?style=flat-square)](https://github.com/dgroup/laconic-velocity/graphs/commit-activity)
[![Hits-of-Code](https://hitsofcode.com/github/dgroup/laconic-velocity)](https://hitsofcode.com/view/github/dgroup/laconic-velocity)[![Build Status](https://travis-ci.org/dgroup/laconic-velocity.svg?branch=master&style=for-the-badge)](https://travis-ci.org/dgroup/laconic-velocity)
[![0pdd](http://www.0pdd.com/svg?name=dgroup/laconic-velocity)](http://www.0pdd.com/p?name=dgroup/laconic-velocity)
[![Dependency Status](https://requires.io/github/dgroup/laconic-velocity/requirements.svg?branch=dev)](https://requires.io/github/dgroup/laconic-velocity/requirements/?branch=dev)
[![Known Vulnerabilities](https://snyk.io/test/github/dgroup/laconic-velocity/badge.svg)](https://snyk.io/org/dgroup/project/58b731a9-6b07-4ccf-9044-ad305ad243e6/?tab=dependencies&vulns=vulnerable)[![DevOps By Rultor.com](http://www.rultor.com/b/dgroup/laconic-velocity)](http://www.rultor.com/p/dgroup/laconic-velocity)
[![EO badge](http://www.elegantobjects.org/badge.svg)](http://www.elegantobjects.org/#principles)
[![We recommend IntelliJ IDEA](http://www.elegantobjects.org/intellij-idea.svg)](https://www.jetbrains.com/idea/)[![Qulice](https://img.shields.io/badge/qulice-passed-blue.svg)](http://www.qulice.com/)
[![SQ passed](https://sonarcloud.io/api/project_badges/measure?project=com.github.dgroup%3Alaconic-velocity&metric=alert_status)](https://sonarcloud.io/dashboard?id=com.github.dgroup%3Alaconic-velocity)
[![Codebeat](https://codebeat.co/badges/7bf04e42-06e8-461f-aea8-ea1e196f22de)](https://codebeat.co/projects/github-com-dgroup-laconic-velocity-master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/011685357fc44898a8538d3e51d8da70)](https://www.codacy.com/app/dgroup/laconic-velocity?utm_source=github.com&utm_medium=referral&utm_content=dgroup/laconic-velocity&utm_campaign=Badge_Grade)
[![Codecov](https://codecov.io/gh/dgroup/laconic-velocity/branch/master/graph/badge.svg?token=Pqdeao3teI)](https://codecov.io/gh/dgroup/laconic-velocity)**ATTENTION**: We're still in a very early alpha version, the API
may and _will_ change frequently. Please, use it at your own risk,
until we release version 1.0.Maven:
```xmlcom.github.dgroup
laconic-velocity```
Gradle:
```groovy
dependencies {
compile 'com.github.dgroup:laconic-velocity:'
}
```
## Get started
**Generate the text/sql/xml/markdown/json/etc based on Apache Velocity [template](/src/main/java/com/github/dgroup/velocity/Template.java).**
1. Define velocity template `query.sql`
```sql
select 1 from dual
#if ($flag)
union
select 2 from dual
#end
```
in
```
velocity $ tree
...
|-- src
| |-- main
| | |-- ...
| |
| `-- test
| |-- java
| | `-- ...
| `-- resources
| `-- velocity
| |-- ...
| |-- query.sql
| |-- ...
...```
2. Define instance of velocity template using
- full path to template
```java
@Test
public void transformSql() throws TemplateException {
MatcherAssert.assertThat(
new Text("query.sql", "src/test/resources/velocity").compose(
new ArgOf("flag", true)
),
Matchers.equalTo(
"select 1 from dual\nunion\nselect 2 from dual\n"
)
);
}
```
See [more](/src/test/java/com/github/dgroup/velocity/template/TextTest.java).
- hierarchical search
```java
@Test
public void hierarchical() throws TemplateException {
MatcherAssert.assertThat(
new Text("query.sql", "src/test/resources").compose(
new ArgOf("flag", true)
),
Matchers.equalTo(
"select 1 from dual\nunion\nselect 2 from dual\n"
)
);
}
```
You can also specify the multiple roots ([more](/src/main/java/com/github/dgroup/velocity/template/Text.java#L64)).
- classpath template
```java
@Test
public void classpath() throws TemplateException {
MatcherAssert.assertThat(
new Text(new RelativePath("velocity/query.sql")).compose(
new ArgOf("flag", true)
),
Matchers.equalTo(
"select 1 from dual\nunion\nselect 2 from dual\n"
)
);
}
```
See [more](/src/test/java/com/github/dgroup/velocity/template/ClasspathTest.java#L124).