[xwiki-devs] Ignore whitespace at the start of the line when parsing Velocity templates
Hi devs, The {{velocity}} macro has a nice filter that removes the whitespace from the start of each line. This allows us to format (indent) the Velocity code without generating whitespace garbage. Recently I had to move some Velocity macros from a wiki page to a Velocity template file and the absence of this filter turned out to be a pita. Even if my macros were generating HTML, consecutive whitespaces were collapsed into a single one which was still visible, breaking my layout a little. Some of my macros were generating Strings which now contained a lot of whitespace. I had to update my functional tests to trim the actual text taken from the UI whenever asserting something. WDYT about applying the same filter when parsing Velocity templates? Do you see any problems with ignoring the whitespace at the start of the line? Thanks, Marius
+1 On Wed, Aug 29, 2012 at 2:46 PM, Marius Dumitru Florea <[email protected]> wrote:
Hi devs,
The {{velocity}} macro has a nice filter that removes the whitespace from the start of each line. This allows us to format (indent) the Velocity code without generating whitespace garbage.
Recently I had to move some Velocity macros from a wiki page to a Velocity template file and the absence of this filter turned out to be a pita. Even if my macros were generating HTML, consecutive whitespaces were collapsed into a single one which was still visible, breaking my layout a little. Some of my macros were generating Strings which now contained a lot of whitespace. I had to update my functional tests to trim the actual text taken from the UI whenever asserting something.
WDYT about applying the same filter when parsing Velocity templates? Do you see any problems with ignoring the whitespace at the start of the line?
Thanks, Marius _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Aug 29, 2012, at 2:46 PM, Marius Dumitru Florea <[email protected]> wrote:
Hi devs,
The {{velocity}} macro has a nice filter that removes the whitespace from the start of each line. This allows us to format (indent) the Velocity code without generating whitespace garbage.
Recently I had to move some Velocity macros from a wiki page to a Velocity template file and the absence of this filter turned out to be a pita. Even if my macros were generating HTML, consecutive whitespaces were collapsed into a single one which was still visible, breaking my layout a little. Some of my macros were generating Strings which now contained a lot of whitespace. I had to update my functional tests to trim the actual text taken from the UI whenever asserting something.
WDYT about applying the same filter when parsing Velocity templates? Do you see any problems with ignoring the whitespace at the start of the line?
Couldn't this cause backward compat issues for templates for which whitespaces at the beginning of lines were used? My POV is that we should use the Rendering engine to parse templates (and even better, remove templates altogether but that could be done in a second step later on). We just need to invent something for handling backward compatibility. It could be based on the file extension since the files would not longer be velocity (vm) files. They could have some other extension, like .xwiki, .x, .txt, .content, .template, .tpl, etc. If we find .vm files we use the old way and if we find the new extension we render them using the Rendering engine. There are lots of pros for doing this and not just the whitespace ignoring. Thanks -Vincent
participants (3)
-
Marius Dumitru Florea -
Thomas Mortagne -
Vincent Massol