11<!-- markdown-link-check-disable -->
22[ ![ Maven Central] ( https://img.shields.io/maven-central/v/io.github.noncat-lang/java-template-engine )] ( https://search.maven.org/artifact/io.github.noncat-lang/java-template-engine )
3- [ ![ ] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/unit-test.yml/badge.svg )] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/unit-test.yml?query=branch%3Amain )
4- [ ![ ] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/semgrep.yml/badge.svg )] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/semgrep.yml?query=branch%3Amain )
5- [ ![ ] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/dependency-check.yml/badge.svg )] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/dependency-check.yml?query=branch%3Amain )
3+ [ ![ Unit Test] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/unit-test.yml/badge.svg )] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/unit-test.yml?query=branch%3Amain )
4+ [ ![ Semgrep] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/semgrep.yml/badge.svg )] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/semgrep.yml?query=branch%3Amain )
5+ [ ![ Dependency Check] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/dependency-check.yml/badge.svg )] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/dependency-check.yml?query=branch%3Amain )
6+ [ ![ Markdown Link Check] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/markdown-link-check.yml/badge.svg )] ( https://github.com/noncat-lang/java-template-engine/actions/workflows/markdown-link-check.yml?query=branch%3Amain )
67<!-- markdown-link-check-enable -->
7-
88# Java Template Engine
99
1010Java Template Engine demonstrates one concept of [ Noncat] ( https://github.com/noncat-lang/noncat ) within the Java programming language.
@@ -20,33 +20,39 @@ Using Java Template Engine one can only define regular languages, hence it is no
2020
2121TODO
2222
23- ### Format
24-
23+ ### Format / Unparse
2524``` Java
26- Token token = Token . of(" [a-zA-Z]+" );
27- Template template = Template . of(" Hello ${name}!" )
28- .withToken(" name" , token);
29-
30- Values values = Values . of(" name" , " World" );
31- String output = template. format(values);
32-
33- System . out. println(output);
25+ createOutput(" new,World" );
26+ ```
27+ ``` Java
28+ String createOutput(String name) {
29+ Token token = Token . of(" [a-zA-Z ]+" ). withEncoding(Encoding . of(" ," , " " ));
30+ Template template = Template . of(" Hello ${name}!" )
31+ .withToken(" name" , token);
32+
33+ Values values = Values . of(" name" , name);
34+ return template. format(values);
35+ }
3436```
3537```
36- Hello World!
38+ Hello new World!
3739```
3840
3941### Parse
4042
4143``` Java
42- Token token = Token . of(" [a-zA-Z]+" );
43- Template template = Template . of(" Hello ${name}!" )
44- .withToken(" name" , token);
45-
46- Values data = template. parse(" Hello World!" );
47-
48- System . out. println(data);
44+ handleInput(" Hello new World!" );
45+ ```
46+ ``` Java
47+ Optional<String > handleInput(String input) {
48+ Token token = Token . of(" [a-zA-Z ]+" ). withDecoding(Decoding . of(" " , " ," ));
49+ Template template = Template . of(" Hello ${name}!" )
50+ .withToken(" name" , token);
51+
52+ Values data = template. parse(input);
53+ return data. get(" name" );
54+ }
4955```
5056```
51- {name= World}
57+ Optional[new, World]
5258```
0 commit comments