agentgt / jatl

JATL : Java Anti-Template Language
Apache License 2.0
45 stars 7 forks source link

whitespace/line break issue #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm somehow wondering whether someone else didn't notice this issue before. It 
seems that in the final HTML rendering it isn't the best choice to draw every 
closing tag at a new line. It looks like that several browsers and e-mail 
client include a whitespace re. that line break. So it might be good if tags 
that include would be closed at the same line, where the text ends.
Or could I work around that issue by specifically initializing the the string 
writer?

Thanks a lot in advance for all your help.  

Original issue reported on code.google.com by zazi0...@googlemail.com on 2 Apr 2012 at 9:45

GoogleCodeExporter commented 9 years ago
Oh, it looks like that my issue is closely relates to issue #10. Unfortunately, 
the fix in version 0.2.1 doesn't seem to fix it for me (i.e., the 
browsers/e-mail clients where I'm testing my HTML code).
Anyway, I found something about "Indent" handling in the lib, which I have to 
investigate a bit more ... ;)

Original comment by zazi0...@googlemail.com on 2 Apr 2012 at 4:10

GoogleCodeExporter commented 9 years ago
.indent(indentSameLine) seems to be the solution. However, I have to manually 
set it at all places where I would like to have this indent behaviour.

Original comment by zazi0...@googlemail.com on 2 Apr 2012 at 5:00

GoogleCodeExporter commented 9 years ago
Yep you can either subclass and make your own Html Builder or sadly you will 
have to set .indent() every where you need it. 

I was going to put in a static variable so that you could set it once but I 
generally try to avoid static singletons because of various class loader issues.

Perhaps I can revisit this issue or look into some factory options. 

Original comment by adam.g...@evocatus.com on 2 Apr 2012 at 5:48

GoogleCodeExporter commented 9 years ago
Thanks a lot for your reply, Adam. Maybe it is still the right way to set it 
manually where you really would like to have the indent on the same line. 
However, I'm wondering how I can achive this behaviour for opening tags as 
well, i.e., if I have, .e.g., a column or paragraph that includes a link. 
Setting .indent(indentSameLine) only forces closing tags to be on the same 
line. Opening tags are always at a new line, or?

Original comment by zazi0...@googlemail.com on 3 Apr 2012 at 8:04

GoogleCodeExporter commented 9 years ago
.indent(indentOff) on the parent node cause the intended effect. cool! ;)

Original comment by zazi0...@googlemail.com on 3 Apr 2012 at 12:32

GoogleCodeExporter commented 9 years ago
Yes indenting is rather strange in that you say the node and then you say how 
you want it indented. That is body().indent(indenter) and not 
indent(indenter).body().

Some examples are here: 
http://code.google.com/p/jatl/source/browse/src/test/java/com/googlecode/jatl/Ht
mlBuilderTest.java#537

Original comment by adam.g...@evocatus.com on 3 Apr 2012 at 3:30

GoogleCodeExporter commented 9 years ago
Yep I should have stated you only have to set the indenter only once on the 
builder (not for every node do you need to set the indenter).

The issue is though you will have to set the indenter every time you do a new 
Builder() {{ indent(indenter); /* build */ }};

Original comment by adam.g...@evocatus.com on 3 Apr 2012 at 3:33

GoogleCodeExporter commented 9 years ago
is it possible to achieve an indenting like theone of my attached filed? (tabs 
are not so important, however the line breaks are important for me)
The only "workaround" I found so far, is to include an empty column that has 
.indent(indentOn) between the first and the second column.

Original comment by zazi0...@googlemail.com on 4 Apr 2012 at 3:45

Attachments:

GoogleCodeExporter commented 9 years ago
Yes it is possible but you will need to make your own custom Indenter, See:

http://site.jatl.googlecode.com/hg/apidocs/com/googlecode/jatl/Indenter.html

and

http://site.jatl.googlecode.com/hg/apidocs/com/googlecode/jatl/MarkupBuilder.htm
l#indent(com.googlecode.jatl.Indenter)

Original comment by adam.g...@evocatus.com on 4 Apr 2012 at 7:12

GoogleCodeExporter commented 9 years ago
Yeah, that might probably be the best option. In general we'll need an indenter 
that would be aware of a 1000-characters-per-line limit as it is manifested in 
RFC 2822 (http://www.ietf.org/rfc/rfc2822.txt) to transfer our HTML messages.

Original comment by zazi0...@googlemail.com on 5 Apr 2012 at 9:50