-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement parentheses support (#727)
- Loading branch information
1 parent
d262d07
commit 02137f5
Showing
6 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Fluid.Parser; | ||
using Xunit; | ||
|
||
namespace Fluid.Tests | ||
{ | ||
public class ParenthesesTests | ||
{ | ||
#if COMPILED | ||
private static FluidParser _parser = new FluidParser(new FluidParserOptions { AllowParentheses = true }).Compile(); | ||
#else | ||
private static FluidParser _parser = new FluidParser(new FluidParserOptions { AllowParentheses = true }); | ||
#endif | ||
|
||
[Fact] | ||
public void ShouldGroupFilters() | ||
{ | ||
Assert.True(_parser.TryParse("{{ 1 | plus : (2 | times: 3) }}", out var template, out var errors)); | ||
Assert.Equal("7", template.Render()); | ||
} | ||
|
||
[Fact] | ||
public void ShouldNotParseParentheses() | ||
{ | ||
var options = new FluidParserOptions { AllowParentheses = false }; | ||
|
||
#if COMPILED | ||
var parser = new FluidParser(options).Compile(); | ||
#else | ||
var parser = new FluidParser(options); | ||
#endif | ||
|
||
Assert.False(parser.TryParse("{{ 1 | plus : (2 | times: 3) }}", out var template, out var errors)); | ||
Assert.Contains(ErrorMessages.ParenthesesNotAllowed, errors); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters