[stringtemplate-interest] Line continuation escape
Terence Parr
parrt at cs.usfca.edu
Wed Nov 17 09:57:27 PST 2010
whoa. hmm...I see this in tests:
public void testLineBreak() throws Exception {
StringTemplate st = new StringTemplate(
"Foo <\\\\>"+newline+
" \t bar" +newline,
AngleBracketTemplateLexer.class
);
StringWriter sw = new StringWriter();
st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
String result = sw.toString();
String expecting ="Foo bar"+newline; // expect \n in output
assertEquals(expecting, result);
}
public void testLineBreak2() throws Exception {
StringTemplate st = new StringTemplate(
"Foo <\\\\> "+newline+
" \t bar" +newline,
AngleBracketTemplateLexer.class
);
StringWriter sw = new StringWriter();
st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
String result = sw.toString();
String expecting ="Foo bar"+newline; // expect \n in output
assertEquals(expecting, result);
}
public void testLineBreakNoWhiteSpace() throws Exception {
StringTemplate st = new StringTemplate(
"Foo <\\\\>"+newline+
"bar" +newline,
AngleBracketTemplateLexer.class
);
StringWriter sw = new StringWriter();
st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
String result = sw.toString();
String expecting ="Foo bar"+newline; // expect \n in output
assertEquals(expecting, result);
}
public void testLineBreakDollar() throws Exception {
StringTemplate st = new StringTemplate(
"Foo $\\\\$"+newline+
" \t bar" +newline,
DefaultTemplateLexer.class
);
StringWriter sw = new StringWriter();
st.write(new AutoIndentWriter(sw,"\n")); // force \n as newline
String result = sw.toString();
String expecting ="Foo bar"+newline; // expect \n in output
assertEquals(expecting, result);
}
Can you derive from that? Are you using latest ST?
Ter
More information about the stringtemplate-interest
mailing list