速度:#if、#else 和#end 之前或之后的空格?
Velocity: Spaces before or after #if, #else and #end?
我继承了几个使用 Velocity 代码的项目。
http://velocity.apache.org/
我的问题可能很简单,对于那些对 Velocity 更有经验的人来说可能有点幼稚,但我必须修复代码中处理 extra spaces
或 missing spaces
的错误。
#if (${INCOMPLETE_ACCOUNT})Click "Use Now" to confirm your new Acme ID account $!{MM_ID}. You will be asked to create a password if you haven’t already done so. #elseClick below to download or sign into your new products.#end
这有效吗?我问同事 else
和 end
之前或之后是否需要空格,但他们声称他们不知道。有人说,"Always put a space before #end
."然而,他们实际上并没有遵守那个规则。
我发现一些文档解释了文本中的 else
(如我上面的示例)应该这样使用:
#if( $foo == $bar)it's true!#{else}it's not!#end
(参见:http://people.apache.org/~henning/velocity/html/ch05s03.html)
问题:我在哪里需要空格? #{else}
目前可以安全使用吗?有一种推荐的方法吗?您如何在代码中使用 #if
、#else
和 #end?
你不需要 spaces 速度:
Velocity's behaviour is to gobble up excess whitespace.
#set($foo=[" and ","a pie"])#foreach($a in $foo)$a#end
有时您无法添加空格,因为您正在渲染的文件不能容忍空格。
关于使用 #{else}
在 else 之后立即写入文本,您可以更改为在之后使用速度注释,如 mailing list:
中所建议
#if( $foo == $bar)it's true!#else#**#it's not!#end
我继承了几个使用 Velocity 代码的项目。 http://velocity.apache.org/
我的问题可能很简单,对于那些对 Velocity 更有经验的人来说可能有点幼稚,但我必须修复代码中处理 extra spaces
或 missing spaces
的错误。
#if (${INCOMPLETE_ACCOUNT})Click "Use Now" to confirm your new Acme ID account $!{MM_ID}. You will be asked to create a password if you haven’t already done so. #elseClick below to download or sign into your new products.#end
这有效吗?我问同事 else
和 end
之前或之后是否需要空格,但他们声称他们不知道。有人说,"Always put a space before #end
."然而,他们实际上并没有遵守那个规则。
我发现一些文档解释了文本中的 else
(如我上面的示例)应该这样使用:
#if( $foo == $bar)it's true!#{else}it's not!#end
(参见:http://people.apache.org/~henning/velocity/html/ch05s03.html)
问题:我在哪里需要空格? #{else}
目前可以安全使用吗?有一种推荐的方法吗?您如何在代码中使用 #if
、#else
和 #end?
你不需要 spaces 速度:
Velocity's behaviour is to gobble up excess whitespace.
#set($foo=[" and ","a pie"])#foreach($a in $foo)$a#end
有时您无法添加空格,因为您正在渲染的文件不能容忍空格。
关于使用 #{else}
在 else 之后立即写入文本,您可以更改为在之后使用速度注释,如 mailing list:
#if( $foo == $bar)it's true!#else#**#it's not!#end