I've been reviewing the various discussions on whitespace. I was not able
to determine if the current proposals cover my thoughts or not, so sorry if
what follows has been covered already.
For the most part, I want my templates to be readable and I use indenting to
accomplish that.
My template might appear as follows:
import com.myco.MyClass;
public Class AnotherClass {
#foreach ($t in $types)
#if ($t.name.contains("_")
Integer $t.name = 0;
#if ($t.type == "static")
// ignore static type $t.name
#end
#end
#end
}
This should produce something like:
import com.myco.MyClass;
public Class AnotherClass {
Integer v_1 = 0;
Integer v_2 = 0;
// ignore static type s_0
}
Given that each line of the nested blocks within template is indented
further, there would need to be some marker in the template to indicate
where indentation should be set for subsequent lines.
import com.myco.MyClass;
public Class AnotherClass {
#setindent ## a new setindent directive
#foreach ($t in $types)
#if ($t.name.contains("_")
Integer $t.name = 0;
#if ($t.type == "static")
// ignore static type $t.name
#end
#end
#end
}
In this example, (there are probably better ways) a #setindent directive
would specify the starting location for all subsequent lines. Velocity
would use the whitespace before the #setindent directive as the amount to
indent any text that is emitted. In this case, all leading whitespace would
be ignored, and indentation would be controlled by the #setIndent
directives.
As I said, if this has been covered already, I'm sorry for the duplicate.
Michael