| | |
| | | } |
| | | |
| | | this.templateLoader.data(map); |
| | | output(template(templateName)); |
| | | } |
| | | Template template = template(templateName); |
| | | template.output(this.outputPath); |
| | | |
| | | // 判断是否有分页,有则执行。从第二页开始 |
| | | int i = 2; |
| | | while(Template.HAS_PAGING) { |
| | | map.put("page", i); |
| | | this.templateLoader.data(map); |
| | | Template pageTemplate = template(templateName); |
| | | pageTemplate.output(this.outputPath); |
| | | i++; |
| | | } |
| | | } |
| | | |
| | | public Template template(String templateName) { |
| | | return template(new File(path(this.templatePath) + templateName)); |
| | |
| | | } |
| | | |
| | | return this.templateLoader.template(file); |
| | | } |
| | | |
| | | // public void columnProcess(Map<String, Object> data, String templateName) { |
| | | // process; |
| | | // } |
| | | // |
| | | // |
| | | // public void articleProcess(Map<String, Object> data, String templateName) { |
| | | // process(data, templateName); |
| | | // } |
| | | |
| | | public void output(Template template) { |
| | | Document document = template.getDocument(); |
| | | List<PartNode> partNodes = template.getPartNodes(); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (PartNode partNode : partNodes) { |
| | | sb.append(partNode.getHtml()); |
| | | } |
| | | document.body().empty().html(sb.toString()); |
| | | String outPath = path(this.outputPath); |
| | | |
| | | String html = document.html(); |
| | | try { |
| | | FileOutputStream outputStream = new FileOutputStream(outPath + template.getName()); |
| | | outputStream.write(html.getBytes()); |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | private String path(String path) { |