You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A null value is being treated as truthy. I can fix it by manually adding truthy check to the compilation builder's config.
Here's a repro Program.cs. I have Stubble.Core and Stubble.Compilation both installed at version 1.9.3.
usingSystem;usingStubble.Compilation.Builders;usingStubble.Core.Builders;namespaceStubbleNullableIntRepro{classProgram{publicclassModel{publicint?Count{get;set;}}staticvoidMain(string[]args){varstubble=newStubbleBuilder().Build();varmodel=newModel();vartemplateString="{{#Count}}Should not be visible{{/Count}}";varoutput=stubble.Render(templateString,model);// Outputs nothing, as expectedConsole.WriteLine("Output from standard:");Console.WriteLine(output);varcompiledStubble=newStubbleCompilationBuilder().Build();varrenderFunc=compiledStubble.Compile<Model>(templateString);varcompiledOutput=renderFunc(model);// Outputs the template, not as expectedConsole.WriteLine("Output from compiled:");Console.WriteLine(compiledOutput);varfixedCompiledStubble=newStubbleCompilationBuilder().Configure(cfg =>cfg.AddTruthyCheck<int?>(input =>input!=null&&input!=0)).Build();varfixedRenderFunc=fixedCompiledStubble.Compile<Model>(templateString);varfixedCompiledOutput=fixedRenderFunc(model);// Outputs nothing, as expectedConsole.WriteLine("Output from fixed compiled:");Console.WriteLine(fixedCompiledOutput);}}}
The text was updated successfully, but these errors were encountered:
A null value is being treated as truthy. I can fix it by manually adding truthy check to the compilation builder's config.
Here's a repro
Program.cs
. I haveStubble.Core
andStubble.Compilation
both installed at version 1.9.3.The text was updated successfully, but these errors were encountered: