|
| 1 | +using Xunit; |
| 2 | + |
| 3 | +namespace HandlebarsDotNet.Test |
| 4 | +{ |
| 5 | + public class Issue458Tests |
| 6 | + { |
| 7 | + [Fact] |
| 8 | + public void Issue458_BasicCompileAndRender_NoByRefDelegate() |
| 9 | + { |
| 10 | + // Validates the scenario that fails on Mono when byref delegates are used |
| 11 | + var h = Handlebars.Create(); |
| 12 | + var render = h.Compile("{{input}}"); |
| 13 | + var result = render(new { input = 42 }); |
| 14 | + Assert.Equal("42", result); |
| 15 | + } |
| 16 | + |
| 17 | + [Fact] |
| 18 | + public void Issue458_BlockHelper_NoByRefDelegate() |
| 19 | + { |
| 20 | + // Block helpers also exercise TemplateDelegate compilation |
| 21 | + var h = Handlebars.Create(); |
| 22 | + h.RegisterHelper("loud", (writer, options, context, arguments) => |
| 23 | + { |
| 24 | + options.Template(writer, context); |
| 25 | + }); |
| 26 | + var render = h.Compile("{{#loud}}hello{{/loud}}"); |
| 27 | + var result = render(new { }); |
| 28 | + Assert.Equal("hello", result); |
| 29 | + } |
| 30 | + |
| 31 | + [Fact] |
| 32 | + public void Issue458_NestedTemplates_NoByRefDelegate() |
| 33 | + { |
| 34 | + // Nested template compilation exercises the expression tree lambda paths |
| 35 | + var h = Handlebars.Create(); |
| 36 | + var render = h.Compile("{{#each items}}{{this}},{{/each}}"); |
| 37 | + var result = render(new { items = new[] { "a", "b", "c" } }); |
| 38 | + Assert.Equal("a,b,c,", result); |
| 39 | + } |
| 40 | + } |
| 41 | +} |
0 commit comments