Handlebars.Net.Helpers icon indicating copy to clipboard operation
Handlebars.Net.Helpers copied to clipboard

Conflict Between Truncate Helpers Prevents Usage Without Prefix

Open EmilyThomasPCTY opened this issue 4 months ago • 1 comments

When registering Handlebars helpers using HandlebarsHelpers.Register with the UseCategoryPrefix option set to false, HandlebarsHelpers.Register(handlebarsContext, options => { UseCategoryPrefix = false; }); it is not possible to use the Truncate helper without a prefix. This is due to a naming conflict between the Truncate helper in the String category and the Truncate helper in the Humanizer category. As a result, the Truncate helper cannot be resolved unambiguously when prefixes are disabled and in my project, Humanizer always seems to win.

Steps to Reproduce

  1. Create a Handlebars context: var handlebarsContext = Handlebars.Create();

  2. Register helpers without category prefixes HandlebarsHelpers.Register(handlebarsContext, options => { options.UseCategoryPrefix = false; });

  3. Attempt to use the string version of the Truncate helper in a Handlebars template: {{Truncate "This is a long string" 10}}

Expected Result: This is a Actual Result: This is a...

EmilyThomasPCTY avatar Aug 28 '25 14:08 EmilyThomasPCTY

@EmilyThomasPCTY OK. Thanks for reporting.

Only way to solve this is to introduce a small breaking change. The least impact is when I require a prefix for the Humanizer truncate.

StefH avatar Aug 28 '25 18:08 StefH

https://github.com/Handlebars-Net/Handlebars.Net.Helpers/pull/132

StefH avatar Sep 12 '25 19:09 StefH