I am using the NVelocity view engine with the latest ASP.NET MVC
framework, preview 3. I cannot figure out how to split a comma
delimited string. Here is what I am trying and it is not working.
#set($myString = "one,two,three,four")
#foreach($str in $myString.Split(","))
$str
#end
I am not sure why this is not working. I can get substring and replace
to work just fine. What is wrong with split? What references should I
be using to see what string functions are available? I have tried the
VTL reference.
I've never used NVelocity with ASP.NET MVC, but I don't know if it is
possible call the Split method from your variable $myString. One
possible reason is that $myString is not created by NVelocity as a
normal C# string. Have you tried do the same with a variable passed
from controller?
> I am using the NVelocity view engine with the latest ASP.NET MVC
> framework, preview 3. I cannot figure out how to split a comma
> delimited string. Here is what I am trying and it is not working.
> #set($myString = "one,two,three,four")
> #foreach($str in $myString.Split(","))
> $str
> #end
> I am not sure why this is not working. I can get substring and replace
> to work just fine. What is wrong with split? What references should I
> be using to see what string functions are available? I have tried the
> VTL reference.
Since I have a string delimited by commas, I need to use split to
create an array to iterate over. I am not sure why split does not
appear to work, nor am I sure what reference documentation I should be
using. For example, is this just VTL documentation, or is this Java
string documentation, or C# strings, ect. The Java docs have a string
util function called split, that I tried that. Then I tried the C#
version of split, and nothing worked there.
Thanks again for any ideas,
Alex
On May 31, 3:28 pm, José Carvalho <jose.barbosa.carva...@gmail.com>
wrote:
> I've never used NVelocity with ASP.NET MVC, but I don't know if it is
> possible call the Split method from your variable $myString. One
> possible reason is that $myString is not created by NVelocity as a
> normal C# string. Have you tried do the same with a variable passed
> from controller?
> On May 31, 10:01 pm, Alex <bamuel...@gmail.com> wrote:
> > I am using the NVelocity view engine with the latest ASP.NET MVC
> > framework, preview 3. I cannot figure out how to split a comma
> > delimited string. Here is what I am trying and it is not working.
> > I am not sure why this is not working. I can get substring and replace
> > to work just fine. What is wrong with split? What references should I
> > be using to see what string functions are available? I have tried the
> > VTL reference.
On Sat, May 31, 2008 at 6:01 PM, Alex <bamuel...@gmail.com> wrote:
> I am using the NVelocity view engine with the latest ASP.NET MVC > framework, preview 3. I cannot figure out how to split a comma > delimited string. Here is what I am trying and it is not working.
> #set($myString = "one,two,three,four")
> #foreach($str in $myString.Split(",")) > $str > #end
> I am not sure why this is not working. I can get substring and replace > to work just fine. What is wrong with split? What references should I > be using to see what string functions are available? I have tried the > VTL reference.
Thanks for the help, both of you. I have moved forward, without the
split, passing the array to my view as needed. Split would sure be
useful in that case.
> On Sat, May 31, 2008 at 6:01 PM, Alex <bamuel...@gmail.com> wrote:
> > I am using the NVelocity view engine with the latest ASP.NET MVC
> > framework, preview 3. I cannot figure out how to split a comma
> > delimited string. Here is what I am trying and it is not working.
> > I am not sure why this is not working. I can get substring and replace
> > to work just fine. What is wrong with split? What references should I
> > be using to see what string functions are available? I have tried the
> > VTL reference.