commit | author | age
|
5a290d
|
1 |
/* |
U |
2 |
http-template - Template extensions to jdk.httpserver |
|
3 |
Copyright (C) 2021 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.httpserver.template; |
|
19 |
|
|
20 |
import com.github.mustachejava.DefaultMustacheFactory; |
|
21 |
import java.io.File; |
|
22 |
import java.io.IOException; |
|
23 |
import java.io.Writer; |
|
24 |
import java.util.logging.Level; |
|
25 |
import java.util.logging.Logger; |
|
26 |
|
|
27 |
/** |
|
28 |
* Eine MustacheFactory die die Methode encode der |
|
29 |
* DefaultMustacheFactory deaktiviert. |
|
30 |
* |
|
31 |
* @author Ulrich Hilger |
|
32 |
* @version 1, 30.06.2021 |
|
33 |
*/ |
|
34 |
public class NeonMustacheFactory extends DefaultMustacheFactory { |
|
35 |
|
|
36 |
/** |
|
37 |
* Eine MustacheFactory erzeugen, die Temlates im Classpath sucht |
|
38 |
*/ |
|
39 |
public NeonMustacheFactory() { |
|
40 |
super(); |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* Eine MustacheFactory erzeugen, die Templates in einem Ordner |
|
45 |
* des Dateisystems sucht. |
|
46 |
* |
|
47 |
* @param fileRoot der Ordner, der als Basis für Dateinamen nebst |
|
48 |
* realtiven PFadangaben dienen soll |
|
49 |
*/ |
|
50 |
public NeonMustacheFactory(File fileRoot) { |
|
51 |
super(fileRoot); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Die DefaultMustacheFactory veraendert HTML-Inhalte ueber die Methode |
|
56 |
* encode. Deshalb wird die MEthode hier ueberschrieben und der Wert in |
|
57 |
* 'value' unveraendert herausgeschrieben. |
|
58 |
* |
|
59 |
* @param value zu schreibender Wert |
|
60 |
* @param writer der Writer, der zum Schreiben genutzt wird |
|
61 |
*/ |
|
62 |
@Override |
|
63 |
public void encode(String value, Writer writer) { |
|
64 |
try { |
|
65 |
writer.write(value); |
|
66 |
//super.encode(value, writer); |
|
67 |
} catch (IOException ex) { |
|
68 |
Logger.getLogger(NeonMustacheFactory.class.getName()).log(Level.SEVERE, null, ex); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
} |