Tigraine
Daniel Hoelbling talks about .NET

Mixing static strings with NVelocity variables

July 14th, 2009 . by Daniel Hölbling

In an ongoing effort to get into NVelocity while programming the iC-Website I wanted to concatenate a filename with the current loop count variable:

<img src="/Content/images/dummy$velocityCount.png" alt="post-image" />

This isn’t working. You’ll end up with dummy$velocityCount.png. While I’d like it to result in dummy1.png.

I suspected it could be solved somehow by using our beloved angle bracket to tell NV to explicitly evaluate my text:

<img src="/Content/images/dummy{$velocityCount}.png" alt="post-image" />

This will result is dummy{1}.png, why is beyond me but NV will parse it. Still this doesn’t really work so I found the solution on how to explicitly invoke NV evaluation in the NV users guide:

<img src="/Content/images/dummy${velocityCount}.png" alt="post-image" />

This is nothing really new, it’s all laid out in the NV users-guide, still especially the second case made me scratch my head for a moment.


blog comments powered by Disqus