| | |
| | | package com.xcong.farmer.cms.core.template; |
| | | |
| | | import com.xcong.farmer.cms.core.node.Template; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | |
| | |
| | | public class TemplateLoader { |
| | | |
| | | private Configuration cfg; |
| | | private List<Template> templates = new ArrayList<>(); |
| | | private Map<String, Object> systemData; |
| | | |
| | | public TemplateLoader() {} |
| | |
| | | } |
| | | |
| | | 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 template = new Template(file, this.systemData); |
| | | template.parser(); |
| | | return template; |
| | | } |