Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surrounding #else directive with curly brackets gives wrong result #15

Open
petrhorny opened this issue Jun 5, 2019 · 1 comment
Open

Comments

@petrhorny
Copy link

According to http://velocity.apache.org/engine/devel/user-guide.html#if-elseif-else

When you wish to include text immediately following a #else directive you will need to use curly brackets immediately surrounding the directive to differentiate it from the following text. (Any directive can be delimited by curly brackets, although this is most useful for #else).

But it doesn't work.

var context = new VelocityContext();
var engine = new VelocityEngine();
var sw = new StringWriter();
var template = "#if(1 == 1)it's true!#{else}it's not!#end";
engine.Init();
engine.Evaluate(context, sw, "", template);
var expected = "it's true!";
Assert.AreEqual(expected, sw.ToString()); // <-- fails, actual (wrong) result is "it's true!#{else}it's not!"
@jonorossi
Copy link
Member

I'm don't think Velocity had this feature when it was originally ported to become NVelocity over a decade ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants