Letractively / jatl

Automatically exported from code.google.com/p/jatl
Apache License 2.0
0 stars 0 forks source link

Add option for newline before end-tag. #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In case of:

    text("[");
    a().href("about.html").text("about").end();
    text("]");

Which outputs:

    [<a href="about.html">about
    </a>]

Then rendered like:

    [about ]    <--  A space before `]`

In short, most of end tags could be on single line.

    <table>
      <tr>
        <td>..</td>
        <td>..</td>
        <td>..</td></tr>
      <tr>
        <td>..</td></tr></table></body></html>

Looks very elegant like Lisp, isn't it?

Original issue reported on code.google.com by x...@99jsj.com on 31 Oct 2011 at 2:24

GoogleCodeExporter commented 8 years ago
Have you seen the new white space indenting?
I can a Lisp like indenting strategy as a feature.

Original comment by adam.g...@evocatus.com on 19 Nov 2011 at 4:03

GoogleCodeExporter commented 8 years ago
Here is an example using a custom indenter to meet your needs:

    @Test
    public void testCustomIndenter() throws Exception {
        final Indenter indenter = new SimpleIndenter("\n", "\t", "", "");
        new Html(writer) {{
            int i = 1;
            indent(indentOff).html().body().indent(indenter);
            table();
            tr();
                td().text("" + i++).end();
                td().text("" + i++).end();
            end();
            tr();
                td().text("" + i++).end();
            endAll();
        }};
        String result = writer.getBuffer().toString();
        String expected = "<html>\n" + 
                "   <body>\n" + 
                "       <table>\n" + 
                "           <tr>\n" + 
                "               <td>1</td>\n" + 
                "               <td>2</td></tr>\n" + 
                "           <tr>\n" + 
                "               <td>3</td></tr></table></body></html>";
        assertEquals(expected, result);
    }

Original comment by adam.g...@evocatus.com on 19 Nov 2011 at 5:12

GoogleCodeExporter commented 8 years ago
Marking invalid since JATL already meets this need.

Original comment by adam.g...@evocatus.com on 19 Nov 2011 at 5:17