简体   繁体   English

城堡nVelocity和whitspace吞噬

[英]Castle nVelocity and whitspace gobbling

I am using Castle nVelocity to create templates to produce some text files. 我正在使用Castle nVelocity创建模板以生成一些文本文件。 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? 有没有办法告诉nVelocity吞噬空白区域,以便该行不会在输出中缩进,而是为了便于阅读,可以将其缩进模板中?

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. 查看使用TransformationFilter http://docs.castleproject.org/MonoRail.Advanced-Topics.ashx#Transformation_Filters_14 ,它可以让您在将数据流发送到客户端之前对其进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM