Handlebars-Net / Handlebars.Net

A real .NET Handlebars engine
MIT License
1.22k stars 213 forks source link

[Question] How to change root vars inside block helper #533

Open mruslan97 opened 1 year ago

mruslan97 commented 1 year ago

Hi all! I'm trying to write a block helper which fill context var. Root access example:

    handlebars.RegisterHelper("example", (output, options, context, arguments) =>  
    {  
          count++;  
          Console.WriteLine($"helper calls: {count}");  
          var root = (JObject)options.Data["root"];  
          root["someVar"] = root["someVar"].ToString() + count;

In this case 27 calls

But result is different

What is the reason and how do I fix this?