This is either the first time i've heard a proposal like this, or else
those who've made such suggestions have not been persistent in them.
If you would like this to be remembered, i'd recommend adding it to
the Wiki page for the whitespace issue:

http://wiki.apache.org/velocity/VelocityWhitespaceGobbling

And as with all the proposals, i've long suspected that patches are
likely to be the deciding factor.  I don't think anyone has so far
produced patches to support their choice (though Christoph may once
upon a time have produced a parser grammar or something like that).
And, as things stand, the consensus seems to be that none of the
proposals are likely to be implemented before Velocity 2.0, due to
concerns over backwards compatibility.

That's not to say, of course, that it is impossible to implement one
of these in a way that is backwards compatible.  It just means that no
one has done it.

On 3/8/07, Michael Giroux <[EMAIL PROTECTED]> wrote:
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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to