Hi All,
I have changed accordingly based on the java file in JIRA, but I've
encountered this problem
Encountered "\r\n" at line 37, column 31.Was expecting one of:
"(" ... <WH
ITESPACE> ... when I use my "#break"
:D
Break.cs
namespace NVelocity.Runtime.Directive
{
public class Break : Directive
{
/**
* simple init - init the tree and get the elementKey from
* the AST
* @param rs
* @param context
* @param node
* @throws TemplateInitException
*/
public override void Init(IRuntimeServices rs,
IInternalContextAdapter context, INode node)
//throws TemplateInitException
{
base.Init(rs, context, node);
}
public override string Name
{
get
{
return "break";
}
set { throw new NotSupportedException(); }
}
/**
* Return type of this directive.
* @return The type of this directive.
*/
public override DirectiveType Type
{
get
{
return DirectiveType.LINE;
}
}
/**
* Break directive does not actually do any rendering.
*
* This directive throws a BreakException (RuntimeException)
which
* signals foreach directive to break out of the loop. Note
that this
* directive does not verify that it is being called inside a
foreach
* loop.
*
* @param context
* @param writer
* @param node
* @return true if the directive rendered successfully.
* @throws IOException
* @throws MethodInvocationException
* @throws ResourceNotFoundException
* @throws ParseErrorException
*/
public override bool Render(IInternalContextAdapter context,
TextWriter writer, NVelocity.Runtime.Parser.Node.INode node)
{
throw new BreakException();
}
}
public class BreakException : System.Exception
{
}
}
and in the Foreach.cs, I modified this part:
try
{
if (isFancyLoop)
{
if (counter == counterInitialValue)
{
ProcessSection(ForeachSectionEnum.BeforeAll, sections, context,
writer);
}
else
{
ProcessSection(ForeachSectionEnum.Between, sections, context, writer);
}
ProcessSection(ForeachSectionEnum.Before,
sections, context, writer);
// since 1st item is zero we invert odd/
even
if ((counter - counterInitialValue) % 2 ==
0)
{
ProcessSection(ForeachSectionEnum.Odd,
sections, context, writer);
}
else
{
ProcessSection(ForeachSectionEnum.Even, sections, context, writer);
}
ProcessSection(ForeachSectionEnum.Each,
sections, context, writer);
ProcessSection(ForeachSectionEnum.After,
sections, context, writer);
}
else
{
bodyNode.Render(context, writer);
}
}
catch
{
bodyNode.Render(context, writer);
break;
}
counter++;
Any suggestion about this? I'm very new about this NVelocity but I
found that the component's very useful :D
Thanks for your helps
Best Regards,
Hatjhie
On Mar 22, 11:02 am, hatjhie <[email protected]> wrote:
> Hi Mauricio,
>
> Thanks a lot for your helps.
>
> I'll try this and once I've tried, I'll update the result.
>
> Best Regards,
> Hatjhie
>
> On Mar 22, 10:00 am, Mauricio Scheffer <[email protected]>
> wrote:
>
> > There are two attached files in the JIRA issue, they implement the feature
> > in Apache Velocity.
> > Download these patches and port them to .NET and NVelocity.
> > NVelocity source code is here:https://github.com/castleproject/NVelocity
>
> > Cheers,
> > Mauricio
>
> > On Mon, Mar 21, 2011 at 10:49 PM, hatjhie <[email protected]> wrote:
> > > Hi All,
>
> > > Thanks for your kind response.
>
> > > I read that there is a break statement in
> > >http://velocity.apache.org/engine/releases/velocity-1.7/user-guide.html
>
> > > However, I'm using Castle NVelocity whose version is 1.1.1.0 for .NET
> > > Framework.
>
> > > Any idea how to implement
> > >https://issues.apache.org/jira/browse/VELOCITY-612
> > > in Castle NVelocity?
>
> > > Thanks a lot for your helps.
>
> > > Best Regards,
> > > Hatjhie
>
> > > On Mar 21, 9:39 pm, Mauricio Scheffer <[email protected]>
> > > wrote:
> > > > TTBOMK #break is not implemented in NVelocity, you might be interested
> > > > in
> > > > porting it from Apache Velocity (seehttps://
> > > issues.apache.org/jira/browse/VELOCITY-612)
> > > > I agree with Patrick though, it's best if you can filter your data
> > > > before
> > > > feeding it to the template...
>
> > > > --
> > > > Mauricio
>
> > > > On Mon, Mar 21, 2011 at 5:35 AM, hatjhie <[email protected]>
> > > wrote:
> > > > > Hi All,
>
> > > > > In NVelocity, it seems like #break operator is not working in my side.
>
> > > > > Is it not supported yet in this version or should I do any setup
> > > > > before I use it?
>
> > > > > Thanks for your helps.
>
> > > > > Best Regards,
> > > > > Hatjhie
>
> > > > > --
> > > > > 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.
>
> > > --
> > > 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.
>
>
--
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.