Skip to content
Merged
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
21 changes: 21 additions & 0 deletions source/Handlebars.Test/IssueTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Xunit;

namespace HandlebarsDotNet.Test
{
public class IssueTests
{
// Issue https://github.com/zjklee/Handlebars.CSharp/issues/7
[Fact]
public void ValueVariableShouldNotBeAccessibleFromContext()
{
var handlebars = Handlebars.Create();
var render = handlebars.Compile("{{value}}");
var output = render(new
{
anotherValue = "Test"
});

Assert.Equal("", output);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace HandlebarsDotNet.ObjectDescriptors
internal class ContextObjectDescriptor : IObjectDescriptorProvider
{
private static readonly Type BindingContextType = typeof(BindingContext);
private static readonly string[] Properties = { "root", "parent", "value" };
private static readonly string[] Properties = { "root", "parent" };

private static readonly ObjectDescriptor Descriptor = new ObjectDescriptor(BindingContextType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ public bool TryGetValue(ref ChainSegment segment, out object value)
value = _context.ParentContext;
return true;

case "value":
value = _context.Value;
return true;

default:
return TryGetContextVariable(_context.Value, ref segment, out value);
}
Expand Down