Skip to content

Commit

Permalink
Fix whitespace in output tags (#346)
Browse files Browse the repository at this point in the history
Fixes #345
  • Loading branch information
sebastienros authored May 25, 2021
1 parent 4ade8d9 commit bd90707
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 19 additions & 1 deletion Fluid.Tests/ParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ public void StringsCanContainCurlies(string source, string expected)
}

[Fact]
public void ShouldSkipNewLines()
public void ShouldSkipNewLinesInTags()
{
var source = @"{%
if
Expand All @@ -539,6 +539,24 @@ public void ShouldSkipNewLines()
Assert.Equal("true", rendered);
}

[Fact]
public void ShouldSkipNewLinesInOutput()
{
var source = @"{{
true
}}";

var result = _parser.TryParse(source, out var template, out var errors);

Assert.True(result, errors);
Assert.NotNull(template);
Assert.Null(errors);

var rendered = template.Render();

Assert.Equal("true", rendered);
}

[Theory]

[InlineData("'' == p", "false")]
Expand Down
4 changes: 2 additions & 2 deletions Fluid/Parser/TagParsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public override bool Parse(ParseContext context, ref ParseResult<TagResult> resu
{
if (_skipWhiteSpace)
{
context.Scanner.SkipWhiteSpace();
context.SkipWhiteSpace();
}

var start = context.Scanner.Cursor.Position;
Expand Down Expand Up @@ -184,7 +184,7 @@ public override bool Parse(ParseContext context, ref ParseResult<TagResult> resu
{
if (_skipWhiteSpace)
{
context.Scanner.SkipWhiteSpace();
context.SkipWhiteSpace();
}

var start = context.Scanner.Cursor.Position;
Expand Down

0 comments on commit bd90707

Please sign in to comment.