[stringtemplate-interest] Newbie question

Brain, Jim JBrain at Aegonusa.com
Mon Oct 26 10:33:09 PDT 2009


I'm a recent ST user, but I've successfully integrated ST into my project (a Template-based XML schema code generator).  I have, though, noticed some things that are not intuitive, even after reading the documentation.

Autoindent?

            StringTemplate st = new StringTemplate("    $reader:{$it$\n\n}$    $writer:{$it$\n\n}$    stuff");
            st.setAttribute("reader", "line1");
            st.setAttribute("reader", "line2");
            st.setAttribute("writer", "line3");
            st.setAttribute("writer", "line4");
            System.out.println(st.toString());

Spits out:

    line1

    line2

    line3

line4

    stuff

I know I'm falling victim to this: "Indentation can only occur at the start of a line so indentation is only tracked in front of attribute expressions following a newline.".  However, adding a newline in front of the second indentation adds an unwanted newline in the resulting code, and it seems problematic to go to a [$reader,$writer] construct to avoid the issue.  Is there a reason why indent cannot be tracked from the end of the last function?

Jim

--
Jim Brain, AFP Architecture, 319-355-2070

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20091026/dd16b328/attachment.html 


More information about the stringtemplate-interest mailing list