Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion source/Octostache.Tests/FiltersFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,16 @@ public void TruncateHandlesNegativeLength()
public void TruncateTruncatesArgumentToSpecifiedLength()
{
var result = Evaluate(@"#{foo | Truncate 7}", new Dictionary<string, string> { { "foo", "Octopus Deploy" } });
result.Should().Be("Octopus...");
result.Should().Be("Octopus");
result.Should().HaveLength(7);
}

[Fact]
public void TruncateTruncatesArgumentToSpecifiedLengthWithCustomSuffix()
{
var result = Evaluate(@"#{foo | Truncate 7 ""<|>""}", new Dictionary<string, string> { { "foo", "Octopus Deploy" } });
result.Should().Be("Octopus<|>");
result.Should().HaveLength(10);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ class TextManipulationFunction
}

var length = int.Parse(options[0]);
var suffix = options.Length == 2 ? options[1] : null;
return length < argument.Length
? $"{argument.Substring(0, length)}..."
? $"{argument.Substring(0, length)}{suffix}"
: argument;
}

Expand Down