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
22 changes: 22 additions & 0 deletions source/Handlebars.Test/Issues/Issue434Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Dynamic;
using Xunit;

namespace HandlebarsDotNet.Test
{
public class Issue434Tests
{
[Fact]
public void Issue434_CaseSensitiveLookupWithSameSpellingVariables()
{
var h = Handlebars.Create();
var template = h.Compile("{{TEST}} {{test}}");
dynamic data = new ExpandoObject();
data.TEST = "Upper";
data.test = "Lower";
var result = template(data);
var parts = result.Split(' ');
Assert.Equal("Upper", parts[0]);
Assert.Equal("Lower", parts[1]);
}
}
}
10 changes: 10 additions & 0 deletions source/Handlebars/Compiler/Translation/Expression/PathBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,27 @@

if (pex.Context == PathExpression.ResolutionContext.Parameter) return resolvePath;
if (pathInfo.IsVariable || pathInfo.IsThis) return resolvePath;
if (!pathInfo.IsValidHelperLiteral && !configuration.Compatibility.RelaxedHelperNaming) return resolvePath;

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Build

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Build

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on macos-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on macos-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on ubuntu-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on ubuntu-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on windows-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on windows-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / SonarCloud

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / SonarCloud

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / SonarCloud

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 39 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Run Benchmark.Net

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

var pathInfoLight = new PathInfoLight(pathInfo);
if (!configuration.Helpers.TryGetValue(pathInfoLight, out var helper))
{
// TODO: use IHelperResolver here as well

Check warning on line 44 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / SonarCloud

Complete the task associated to this 'TODO' comment.
var lateBindHelperDescriptor = new LateBindHelperDescriptor(pathInfo);
helper = new Ref<IHelperDescriptor<HelperOptions>>(lateBindHelperDescriptor);
configuration.Helpers.AddOrReplace(pathInfoLight, helper);
}
else if (helper.Value is LateBindHelperDescriptor existingLateBindHelper
&& !string.Equals(existingLateBindHelper.Name.Path, pathInfo.Path, System.StringComparison.Ordinal))
{
// The helpers dictionary uses case-insensitive keys, so "TEST" and "test" map to the
// same slot. If the cached LateBindHelperDescriptor was stored for a differently-cased
// path, create a new one that carries the exact casing of the current expression so
// that runtime property lookup resolves to the right member.
var lateBindHelperDescriptor = new LateBindHelperDescriptor(pathInfo);
helper = new Ref<IHelperDescriptor<HelperOptions>>(lateBindHelperDescriptor);
}
else if (configuration.Compatibility.RelaxedHelperNaming)

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Build

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Build

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on macos-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on macos-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on ubuntu-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on windows-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Tests on windows-latest

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / SonarCloud

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / SonarCloud

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / SonarCloud

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'

Check warning on line 59 in source/Handlebars/Compiler/Translation/Expression/PathBinder.cs

View workflow job for this annotation

GitHub Actions / Run Benchmark.Net

'Compatibility.RelaxedHelperNaming' is obsolete: 'Toggle will be removed in the next major release'
{
pathInfoLight = pathInfoLight.TagComparer();
if (!configuration.Helpers.ContainsKey(pathInfoLight))
Expand Down
Loading