Helius
2022-07-05 801957b18d01265e162c9ab5e14c8a5d7c6db389
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.xcong.farmer.cms.core.template;
 
import com.xcong.farmer.cms.core.node.Template;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
 
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
public class TemplateLoader {
 
    private Configuration cfg;
    private Map<String, Object> systemData;
 
    public TemplateLoader() {}
 
    public TemplateLoader(Configuration cfg) {
        this.cfg = cfg;
    }
 
    public Template template(File file) {
        Document document = null;
        try {
            document = Jsoup.parse(file, "utf-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
 
        if (document == null) {
            throw new NullPointerException();
        }
 
        Template template = new Template();
        template.setDocument(document);
        template.setName(file.getName());
        template.systemData(this.systemData);
 
        template.parser();
        return template;
    }
 
    public void data(Map<String, Object> systemData) {
        this.systemData = systemData;
    }
 
}