Skip to content

How to treat 0 as truthy #285

Description

@sellomkantjwa

I tried using

testing Var: 
{{#if var includeZero=true}}
    var is set to {{var}}
{{/if}}

but I get

Unhandled Exception: System.InvalidOperationException: Sequence contains more than one element
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at HandlebarsDotNet.Compiler.ConditionalBlockAccumulatorContext..ctor(Expression startingNode)
   at HandlebarsDotNet.Compiler.BlockAccumulatorContext.Create(Expression item, HandlebarsConfiguration configuration)
   at HandlebarsDotNet.Compiler.BlockAccumulator.ConvertTokens(IEnumerable`1 sequence)+MoveNext()
   at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at HandlebarsDotNet.Compiler.ExpressionBuilder.ConvertTokensToExpressions(IEnumerable`1 tokens)
   at HandlebarsDotNet.Compiler.HandlebarsCompiler.Compile(TextReader source)
   at HandlebarsDotNet.Handlebars.HandlebarsEnvironment.Compile(String template)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions