commit | author | age
|
3ff4c5
|
1 |
/* |
U |
2 |
neon-template - Template extensions to Neon |
|
3 |
Copyright (C) 2024 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
package de.uhilger.neon.template; |
|
19 |
|
|
20 |
import com.github.mustachejava.DefaultMustacheFactory; |
|
21 |
import java.io.File; |
|
22 |
import java.io.IOException; |
|
23 |
import java.io.Writer; |
|
24 |
|
|
25 |
/** |
|
26 |
* Eine MustacheFactory die die Methode encode der |
|
27 |
* DefaultMustacheFactory deaktiviert. |
|
28 |
* |
|
29 |
* @author Ulrich Hilger |
|
30 |
* @version 1, 30.06.2021 |
|
31 |
*/ |
|
32 |
public class NeonMustacheFactory extends DefaultMustacheFactory { |
|
33 |
|
|
34 |
/** |
|
35 |
* Eine MustacheFactory erzeugen, die Temlates im Classpath sucht |
|
36 |
*/ |
|
37 |
public NeonMustacheFactory() { |
|
38 |
super(); |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* Eine MustacheFactory erzeugen, die Templates in einem Ordner |
|
43 |
* des Dateisystems sucht. |
|
44 |
* |
|
45 |
* @param fileRoot der Ordner, der als Basis für Dateinamen nebst |
|
46 |
* realtiven PFadangaben dienen soll |
|
47 |
*/ |
|
48 |
public NeonMustacheFactory(File fileRoot) { |
|
49 |
super(fileRoot); |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Die DefaultMustacheFactory veraendert HTML-Inhalte ueber die Methode |
|
54 |
* encode. Deshalb wird die MEthode hier ueberschrieben und der Wert in |
|
55 |
* 'value' unveraendert herausgeschrieben. |
|
56 |
* |
|
57 |
* @param value zu schreibender Wert |
|
58 |
* @param writer der Writer, der zum Schreiben genutzt wird |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public void encode(String value, Writer writer) { |
|
62 |
try { |
|
63 |
writer.write(value); |
|
64 |
} catch (IOException ex) { |
|
65 |
ex.printStackTrace(); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
} |