Skip to content

More Handlebars helpers#5937

Open
bubblobill wants to merge 16 commits intoRPTools:developfrom
bubblobill:handlebarsHelpers
Open

More Handlebars helpers#5937
bubblobill wants to merge 16 commits intoRPTools:developfrom
bubblobill:handlebarsHelpers

Conversation

@bubblobill
Copy link
Collaborator

@bubblobill bubblobill commented Feb 12, 2026

Identify the Bug or Feature request

progresses #4158

Description of the Change

added handlebars helpers.
added template cache.

  • New class HandlebarsHelpers to contain helpers.
  • Helper registration moved to HandlebarsHelpers.

LibraryTemplateLoader class changes:

Normally it is not noticable, but on consecutive nested calls (i.e. calls to templates inside a template, as used in the include helper), Windows paths break the URL lookup, .e.g. when the first character is checked for / but it is a \.

New helper list;

previously existing helpers
  • StringHelpers:
    • capitalizeFirst,
    • center,
    • cut,
    • defaultIfEmpty,
    • join,
    • ljust,
    • rjust,
    • substring,
    • lower,
    • upper,
    • slugify,
    • stringFormat,
    • stripTags,
    • capitalize,
    • abbreviate,
    • wordWrap,
    • replace,
    • yesno,
    • dateFormat,
    • numberFormat
  • ConditionalHelpers:
    • eq,
    • neq,
    • gt,
    • gte,
    • lt,
    • lte,
    • and,
    • or,
    • not
  • NumberHelpers:
    • isEven
    • isOdd
    • stripes
  • AssignHelper:
    • assign
  • IncludeHelper:
    • include
  • Base64EncodeHelper
    • base64Encode
new helpers
  • Jackson2Helper:
    • json
  • MarkdownHelper:
    • markdown
  • MathsHelpers:
    • add,
    • subtract,
    • multiply,
    • divide,
    • max,
    • min,
    • mod,
    • div,
    • pow,
    • abs,
    • sqrt,
    • tau,
    • pi

Possible Drawbacks

things don't work as I think they should

Documentation Notes

added handlebars helpers.


This change is Reviewable

Added cache.
Moved in-house helpers to a separate class.
Added helpers for mark-down, simple maths, and string comparison.
…lpers

# Conflicts:
#	src/main/java/net/rptools/maptool/util/HandlebarsUtil.java
Added HBLogger to helper registrations.
faster).
Added HandlebarsHelperTest with tests for maths helpers.
HandlebarsHelpers;
- added debug logging to maths helpers.
- added number of parameters checks to maths helpers.
- set the MathContext for BigDecimal operations.
- miscellaneous bug fixes to maths helpers.
- improved argument parsing to accept literal array strings, and
named arguments.
StrListFunctionsTest: fixed annoying type cast message.
Change portrait on mouseover to portrait on stat-sheet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants