zhcms内置的模板引擎(二)

原创
2014/04/06 01:55
阅读数 461

因为没有考虑效率,所以我使用了读取文件然后进行文件内容的处理这种方式进行了代码的编写思路。

读取文件的核心代码

    StringBuilder strContent1 = new StringBuilder("");
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f), iCharset));
            String iline = null;
            while ((iline = br.readLine()) != null) {
                strContent1.append(iline.toString());
                strContent1.append("\n");
            }
            br.close();
        } catch (IOException e) {
            //
        }

然后开始进行分析处理

public void parse() {
        try {
            gydContent.setContent(readFile(this.gytFile));
            // 处理include标签
            RepInclude();
            // 处理判断
            RepIf();
            // 处理循环
            RepFor();
            // 处理替换的标签
            RepString();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

写这个地方的时候一直比较纠结就是处理的顺序,最后定成这个顺序了。

今天先写到这,以后继续

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
0 评论
2 收藏
0
分享
返回顶部
顶部