public static Tmpl parse(String tmpl,
                             final String startChar,
                             String leftBrace,
                             String rightBrace) {
        if (null == tmpl)
            return null;
        String regex = "((?<!["
                       + startChar
                       + "])["
                       + startChar
                       + "]["
                       + ("[".equals(leftBrace) ? "\\[" : leftBrace)
                       + "]([^"
                       + ("]".equals(rightBrace) ? "\\]" : rightBrace)
                       + "]+)["
                       + rightBrace
                       + "])|(["
                       + startChar
                       + "]["
                       + startChar
                       + "])";
        Pattern ptn = Pattern.compile(regex);
        return new Tmpl(tmpl, ptn, 2, 3, new TmplEscapeStr() {
            public String get(Matcher m) {
                return startChar;
            }
        });
    }
public static Tmpl parse(String tmpl,
                             final String startChar,
                             String leftBrace,
                             String rightBrace) {
        if (null == tmpl)
            return null;
        String regex = "((?<!["
                       + startChar
                       + "])["
                       + startChar
                       + "]["
                       + ("[".equals(leftBrace) ? "\\[" : leftBrace)
                       + "]([^"
                       + ("]".equals(rightBrace) ? "\\]" : rightBrace)
                       + "]+)["
                       + rightBrace
                       + "])|(["
                       + startChar
                       + "]["
                       + startChar
                       + "])";
        Pattern ptn = Pattern.compile(regex);
        return new Tmpl(tmpl, ptn, 2, 3, new TmplEscapeStr() {
            public String get(Matcher m) {
                return startChar;
            }
        });
    }
public static Tmpl parse ( String tmpl , final String startChar , String leftBrace , String rightBrace ) { if ( null == tmpl ) return null ; String regex = "((?<![" + startChar + "])[" + startChar + "][" + ( "[" . equals ( leftBrace ) ? "\\[" : leftBrace ) + "]([^" + ( "]" . equals ( rightBrace ) ? "\\]" : rightBrace ) + "]+)[" + rightBrace + "])|([" + startChar + "][" + startChar + "])" ; Pattern ptn = Pattern . compile ( regex ) ; return new Tmpl ( tmpl , ptn , 2 , 3 , new TmplEscapeStr ( ) { public String get ( Matcher m ) { return startChar ; } } ) ; }
解析模板对象, 并用上下文进行渲染。

@param tmpl
模板字符串
@param startChar
占位符起始标示符
@param leftBrace
左侧括号
@param rightBrace
右侧括号
@return 模板对象
解析模板对象 并用上下文进行渲染。