I am using Castle nVelocity to create templates to produce some text files. I have found that if I do something like the following in my template, that my output line is indented in the resulting file as it is in the template.

#foreach( $row in $report.Rows )
    Output this row: ${row}
#end

To get the output I want I have to write my template like this:

#foreach( $row in $report.Rows )
Output this row: ${row}
#end

Is there a way to tell nVelocity to gobble the white space so that the line will not be indented in the output but so that I can leave it indented in the template for readability?

有帮助吗?

解决方案

No you cannot do this with out of the box functionality.

Look into using a TransformationFilter http://docs.castleproject.org/MonoRail.Advanced-Topics.ashx#Transformation_Filters_14 which will allow you to manipulate the stream of data before it is sent to the client.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top