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 |
|
|
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 |
//super.encode(value, writer); |
|
65 |
} catch (IOException ex) { |
31d9df
|
66 |
//Logger.getLogger(NeonMustacheFactory.class.getName()).log(Level.SEVERE, null, ex); |
U |
67 |
ex.printStackTrace(); |
5a290d
|
68 |
} |
U |
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
} |