Discussion:
[FreeMarker-user] Option for setting default mode for compress directive
Daniel Dekany
2014-12-16 11:48:37 UTC
Permalink
Hi all,
I checked the source code for CompressedBlock and StandardCompress and
found the undocumented argument single_line(boolean) which is exactly
the feature I'm looking for. I'm using Freemarker for html development
and I have a lot of macros that sometimes are nested to construct html
fragments. However using compress today when it outputs newlines is
inconvenient since the output becomes really ugly (imho).
So I was wondering if there would be a possibility in next version of
Freemarker to set an option somewhere to have compress to always use
single_line=true which would make me very happy :).
Have a good day everyone!
//Jerker
A global settings that change the behavior of a standard directive is
not something I like. Because, then if you want to reuse or just see a
template somewhere, you can't be sure anymore what will it do, as that
depends on a FreeMarker setting that's maybe set somewhere in the
middle of a Java code. You as the template author has no control over
that. Is there a problem with <#compress single_line=true>...</#compress>
(other than missing documentation, as you say)? Do you have to use it
often in the source code? Any other ideas other than a global option?
Can you demonstrate the use case a bit more?

(The ultimate solution would be better parse-time whitespace gobbling,
but that's again planned but still far away. Right now you could use
#t and such, though I guess it's too messy to put that all around. I
still wonder if with what *parse-time* feature could your problem be
addressed... any idea?)
--
Thanks,
Daniel Dekany
Loading...