Skip to content

More Handlebars helpers#5937

Closed
bubblobill wants to merge 0 commit intoRPTools:developfrom
bubblobill:handlebarsHelpers
Closed

More Handlebars helpers#5937
bubblobill wants to merge 0 commit intoRPTools:developfrom
bubblobill:handlebarsHelpers

Conversation

@bubblobill
Copy link
Copy Markdown
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

@Nonnull
public String resolve(@Nonnull final String path) {
var location = current.resolveSibling(path).normalize().toString();
var location = current.resolveSibling(path).normalize().toString().replace('\\', '/');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed, please remove and just use / not \ as you are supposed to in a URL! Don't let windows path seperator start infecting things

private static final HighConcurrencyTemplateCache HIGH_CONCURRENCY_TEMPLATE_CACHE =
new HighConcurrencyTemplateCache();

static Handlebars getHandlebarsInstance(@Nullable TemplateLoader loader) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some Javadoc that explaines what happens this method, especially what happens if loader is null as it wont be obvious to anyone but it is marked as nullable

@bubblobill
Copy link
Copy Markdown
Collaborator Author

What the hell - grrrr... I did not close this - damnit

@bubblobill
Copy link
Copy Markdown
Collaborator Author

Reopen damn you

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