Hello,

I have been struggling with this all weekend.  I am hoping someone can
help me with this.  I have the following template.

hasShippingInfo : $hasShippingInfo
#if($hasShippingInfo)
<P style=""FONT-FAMILY: Arial, Verdana, sans-serif; COLOR: #252525;
FONT-SIZE: 12px"">
        <B>Shipping Method:</B> $ShippingMethod<BR>
</P>
#end

The output I got is

hasShippingInfo : True
<P style="FONT-FAMILY: Arial, Verdana, sans-serif; COLOR: #252525;
FONT-SIZE: 12px">
        <B>Shipping Method:</B> FedEx<BR>
</P>

It seems that NVelocity is not evaluating the if condition correctly.
It returns false even though $hasShippingInfo is true, as shown in the
output.

The code I am using is as follows:

            // this data context is initialized somewhere else.
            var dataContext= new Hashtable();
            dataContext.Add("hasShippingInfo", hasShippingInfo);
            dataContext.Add("ShippingMethod", "FedEx");

            // the following code snippet are part of a emailer.
            var context = new VelocityContext(DataContext);

            Velocity.Init();

            using (var writer = new StringWriter())
            {
                if (!Velocity.Evaluate(context, writer, string.Empty,
Template))
                {
                    throw new Exception(string.Format("NVelocity
encountered errrors evaulating template:\n{0}", Template));
                }

                content = writer.ToString();
            }

When I take code out and put it into a console app, it works.
NVelocity evalutes #if($hasShippingInfo) correct.  In other words,
$hasShippingInfo is true and the whole #if condition is true, and my
output is rendered.

But when I use it in an Emailer, that is used by a ASP.NET site, it
fails.  NVelcoity evaulates the #if condition as false even though
$hasShippingInfo is true.

Any help is much appreciated.
An

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to