diff --git a/source/Handlebars.Test/IssueTests.cs b/source/Handlebars.Test/IssueTests.cs new file mode 100644 index 00000000..3bad21f2 --- /dev/null +++ b/source/Handlebars.Test/IssueTests.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/source/Handlebars/ObjectDescriptors/ContextObjectDescriptor.cs b/source/Handlebars/ObjectDescriptors/ContextObjectDescriptor.cs index 8b8fc2e5..665f1948 100644 --- a/source/Handlebars/ObjectDescriptors/ContextObjectDescriptor.cs +++ b/source/Handlebars/ObjectDescriptors/ContextObjectDescriptor.cs @@ -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) { diff --git a/source/Handlebars/ValueProviders/BindingContextValueProvider.cs b/source/Handlebars/ValueProviders/BindingContextValueProvider.cs index 4aef53df..7f14d320 100644 --- a/source/Handlebars/ValueProviders/BindingContextValueProvider.cs +++ b/source/Handlebars/ValueProviders/BindingContextValueProvider.cs @@ -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); }