Search in sources :

Example 1 with Interpreter

use of org.stringtemplate.v4.Interpreter in project bndtools by bndtools.

the class StringTemplateEngine method extractAttrs.

private void extractAttrs(ST st, final Map<String, String> attrs) throws Exception {
    Interpreter interpreter = new Interpreter(st.groupThatCreatedThisInstance, Locale.getDefault(), true) {

        @Override
        public Object getAttribute(InstanceScope scope, String name) {
            attrs.put(name, null);
            return "X";
        }
    };
    StringWriter writer = new StringWriter();
    interpreter.exec(new AutoIndentWriter(writer), new InstanceScope(null, st));
}
Also used : AutoIndentWriter(org.stringtemplate.v4.AutoIndentWriter) Interpreter(org.stringtemplate.v4.Interpreter) StringWriter(java.io.StringWriter) InstanceScope(org.stringtemplate.v4.InstanceScope)

Aggregations

StringWriter (java.io.StringWriter)1 AutoIndentWriter (org.stringtemplate.v4.AutoIndentWriter)1 InstanceScope (org.stringtemplate.v4.InstanceScope)1 Interpreter (org.stringtemplate.v4.Interpreter)1