Skip to content

Bump Handlebars.Net from 2.4.3 to 2.5.0 - #17855

Open
dependabot[bot] wants to merge 1 commit into
mainfrom
dependabot/nuget/Handlebars.Net-2.5.0
Open

dependabot[bot] wants to merge 1 commit into
mainfrom
dependabot/nuget/Handlebars.Net-2.5.0

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Nov 30, 2026

Copy link
Copy Markdown
Contributor

Updated Handlebars.Net from 2.4.3 to 2.5.0.

Release notes

Sourced from Handlebars.Net's releases.

2.5.0

2.5.0 brings Handlebars.Net closer to handlebars.js. It adds JsonNode support, and compile errors now report where they happened. Several long-standing differences from handlebars.js are now fixed by default. Each fix that changes output for templates that used to compile has a Configuration.Compatibility flag that restores the old behavior, and the new compile errors name that flag. All compatibility flags are read at compile time, so set them before calling Compile.

Compatibility notes

These changes can alter output, or turn a template that used to compile into an error. Read them before upgrading.

  • A standalone {{^}} inside a block is now the inverse separator, the same as {{else}}, as in handlebars.js. This applies to #if, #unless, #each, #with, sections and custom block helpers, and to the {{^ }} and {{~^~}} forms. Inside raw blocks {{^}} is still literal text. To restore the previous behavior, set Compatibility.LegacyStandaloneCaretBehavior = true. (#​675, fixes #​672; #​692)

    Template Data Before 2.5.0
    {{#if condition}}yes{{^}}no{{/if}} condition=true yes{ condition = True }no yes
    {{#if condition}}yes{{^}}no{{/if}} condition=false (empty) no
    {{#each people}}{{name}}{{^}}No one{{/each}} [] (empty) No one

    A second {{^}} in the same #if / #unless (e.g. {{#if x}}a{{^}}b{{^}}c{{/if}}) is now a compile error, and its message names the opt-out.

  • Inline partials declared inside a block or partial are now scoped to that block, as in handlebars.js. The new Compatibility.BlockScopedInlinePartials setting defaults to true. To restore the previous behavior, where such partials leaked into the enclosing scope and replaced outer partials with the same name, set it to false. When a partial can't be resolved because of this scoping, the error message names the opt-out. (#​688, #​692, fixes #​673, #​690)

    Template Before 2.5.0
    {{#*inline "p"}}outer{{/inline}}{{#with .}}{{#*inline "p"}}inner{{/inline}}{{> p}}{{/with}} {{> p}} inner inner inner outer
    {{#with .}}{{#*inline "myPartial"}}success{{/inline}}{{/with}}{{> myPartial}} success throws: partial could not be resolved
    {{> macros}}{{> button label="OK"}}, where partial macros declares {{#*inline "button"}} <button>OK</button> throws: partial could not be resolved

    To migrate, move such declarations to the top level of the template or register them with RegisterTemplate. Either works with the setting on or off.

  • {{else …}} chains under {{#if}} / {{#unless}} now follow handlebars.js. {{else name args}} now means {{else}}{{#name args}}…{{/name}}. Before, any two-word form was treated as {{else if x}}, and any other form silently became a plain {{else}}. (#​687, #​689, #​696, fixes #​683, #​695; based on #​684 by @​EnesKartal)

    • {{else unless x}} now has unless semantics. Before, it was evaluated as {{else if x}}, which inverted the condition.
    • {{else someHelper x}} now invokes someHelper. Before, it ignored the helper and used x as the condition. If the helper isn't registered, rendering throws the usual missing-helper HandlebarsRuntimeException.
    • A bare {{else name}} now opens a block on name. If name is a registered block helper it is invoked. Otherwise the branch renders only when name is truthy, and iterates when it is a list. A bare {{else if}} / {{else unless}} with no condition is now a compile error. To restore the previous bare-name behavior, where the name was ignored and the branch rendered as a plain {{else}}, set the new Compatibility.LegacyBareElseNameBehavior = true.
    • {{else if a b}} / {{else unless a b}} (too many arguments) and {{else}} followed by another {{else}} now throw HandlebarsCompilerException. Before, these rendered the branch or threw ArgumentNullException.
    • Chains that used to throw ArgumentNullException now work: {{else if b includeZero=true}}, and a custom-helper chain followed by {{else}}.
    Template Data Before 2.5.0
    {{#if user.isAdmin}}Admin tools{{else user.isModerator}}Moderator tools{{/if}} neither admin nor moderator Moderator tools (empty)
    {{#if a}}A{{else unless b}}B{{else}}C{{/if}} a=false, b=false C B
    {{#if a}}A{{else ifEq b "y"}}B{{/if}} (ifEq registered) a=false, b="x" B (empty)
    {{#if a}}A{{else items}}[{{this}}]{{/if}} a=false, items=[1,2] [ + outer context + ] [1][2]
    {{#if a}}A{{else if}}B{{/if}} a=false B HandlebarsCompilerException
  • JsonNode behavior (#​670 by @​jsneedles):

    • false, 0 and "" in a JsonNode are now falsy in #if and similar helpers. Before, they were truthy.
    • JsonObject member lookups now fall back to the lowercase name, as JsonElement lookups do.
    • Custom member alias providers are now consulted for unresolved JsonElement and JsonObject members.
  • Compile error messages and exception types:

    • {{#if}} / {{#unless}} with no argument now throws HandlebarsCompilerException (#if requires exactly one argument). Before, it threw InvalidOperationException. With too many arguments, it throws the same exception type as before, but the message now reads the same way. (#​678, fixes #​674)
    • When a compile error has a known position, its message now ends with Line n, column n. followed by the template line and a caret under the error. The old Occured at: n:n text is gone. Code that compares the full message exactly, or searches it for Occured at:, needs updating. Use the new HandlebarsException.Line / Column properties instead. (#​680, #​681, #​682, fixes #​314)

New features

... (truncated)

2.4.4

New features

  • System.Text.Json JsonNode support. You can now pass JsonObject, JsonArray and JsonValue into templates directly. They support the same things as JsonElement: member access, #each with @​index/@​key/@​first/@​last, truthiness, includeZero and partials. JsonElement also gains array index access ({{items.[0]}}, {{lookup items 1}}), {{items.Count}} (plus {{items.length}} with UseCollectionMemberAliasProvider()), and support for custom alias providers. New public types: JsonNodeObjectDescriptorProvider, JsonNodeMemberAccessor, JsonNodeIterator. JsonElementObjectDescriptorProvider and JsonElementMemberAccessor get new constructor overloads that take alias providers. (#​670)
  • Error locations on exceptions. HandlebarsException has new Line and Column properties (int?, zero-based, null when the location isn't known). The derived compiler, parser and runtime exceptions inherit them. When a compile-time error has a location, its message now ends with the offending template line and a caret under the column. (#​681, refs #​314)
  • Clearer messages for common syntax errors. {{#if !x}} now says that ! isn't a negation operator and points you to #unless. Unclosed blocks, stray closing tags and mismatched }}} now report where they happened. (#​680, refs #​314)
  • Compatibility.BlockScopedInlinePartials (opt-in, default false): when enabled, an inline partial declared inside a block or an included partial is visible only within that block and its children, as in Handlebars.js. With the default, existing behavior is unchanged. (#​688, refs #​673)
  • Compatibility.LegacyStandaloneCaretBehavior: a new opt-out flag that restores the old {{^}} behavior (see Fixes). (#​675, fixes #​672)

Fixes

  • A standalone {{^}} inside a block (also {{^ }} and {{~^~}}) is now the inverse separator, the same as {{else}}, matching Handlebars.js. Inside raw blocks it stays literal text. (#​675, fixes #​672)
  • {{else name args}} under {{#if}}/{{#unless}} now chains to the named helper, as in Handlebars.js. Previously it was evaluated as {{else if …}}, or the condition was silently dropped. {{else unless x}} now has unless semantics, and {{else with x}} chains to the built-in with. (#​687, #​689, fixes #​683)
  • {{#if}}/{{#unless}} with a missing argument now throw HandlebarsCompilerException instead of a bare InvalidOperationException. (#​678, fixes #​674)
  • Raw block helpers now compile when Compatibility.RelaxedHelperNaming = true. (#​677, fixes #​676)
  • {{#each}} over items of different runtime types now looks each item's members up by its own type. Before, a dictionary followed by a number threw InvalidCastException, and a number followed by a dictionary rendered empty. For example, {{#each items}}[{{name}}]{{/each}} over [{name: "Erik"}, 42, {name: "Helen"}] now renders [Erik][][Helen]. Collections whose items all share one type behave as before. (#​691, fixes #​685)
  • JsonArray member access is limited to indexes, Count and configured aliases, so Parent/Root/Options no longer resolve through reflection. Scalar JsonValues read through JsonSerializer no longer throw. (#​670)

Internal

  • Sealed ReusableStringWriter (it has only a private constructor, so this doesn't break anything), and split up Tokenizer/LiteralParser methods for the SonarCloud S3881/S3776 items. No behavior change. (#​679, closes #​641)

Compatibility notes

Some templates and code that worked before will behave differently:

  • {{^}} inside a block used to render the current context, and the block had no inverse branch. It is now {{else}}. For example, {{#if condition}}yes{{^}}no{{/if}} with condition = true used to render yes{ condition &#x3D; True }no and now renders yes. With condition = false it used to render nothing and now renders no. To restore the old output, set Configuration.Compatibility.LegacyStandaloneCaretBehavior = true. (#​675)
  • {{else unless x}} under {{#if}} used to be evaluated as {{else if x}}, which inverted the condition. {{else someHelper x}} used to ignore someHelper. It now calls it, and throws the usual missing-helper HandlebarsRuntimeException if someHelper isn't registered. {{else if a b}} and {{else unless a b}} (too many arguments) and a second {{else}} now fail at compile time. Plain {{else}}, {{else if x}} and a bare {{else name}} are unchanged. (#​687)
  • Exception messages: the location text changed from Occured at: l:c to Line l, column c., and located compile errors now end with a source line and a caret. Code that matches on the exception type or message prefix keeps working. Code that searches for Occured at: or compares the full Message will not match. Use the new Line/Column properties instead. {{#if}} with no argument now throws HandlebarsCompilerException instead of InvalidOperationException. With too many arguments, it now says #if requires exactly one argument. (#​678, #​680, #​681, #​682)
  • JsonNode: false, 0 and "" are now falsy in #if/#unless/#each. Before, they were truthy. JsonObject lookups now fall back to the lowercase property name. Custom member alias providers are now consulted for JsonElement and JsonObject members that don't otherwise resolve. When interpolated directly, JsonNode booleans still render as true/false, while JsonElement booleans render as True/False. (#​670)

Contributors: @​jsneedles (JsonNode support), @​EnesKartal (#​684, whose test case and approach were incorporated into #​687/#​689), @​bardrop (#​686, whose fix and tests were incorporated into #​691), @​rexm

Full Changelog: Handlebars-Net/Handlebars.Net@2.4.3...2.4.4

Commits viewable in compare view.

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

---
updated-dependencies:
- dependency-name: Handlebars.Net
  dependency-version: 2.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot Bot added .NET Pull requests that update .NET code dependencies Pull requests that update a dependency file labels Nov 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file .NET Pull requests that update .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants