Skip to content

Conversation

@najuna-brian
Copy link
Contributor

Description

Fixes handlebars template syntax in labels that was not being expanded. Labels with syntax like {{data.fieldName}} now properly replace placeholders with actual form data values.

Changes

  • Added handlebars template processing in HtmlLabelRenderer.tsx
  • Uses useJsonForms() hook to access form data reactively
  • Processes {{data.fieldName}} syntax to replace with actual values
  • Handles missing values gracefully (replaces with empty string)
  • Maintains backward compatibility with labels without handlebars syntax

Testing

✅ Tested on phone with p_wealth_new form - handlebars templates now expand correctly

  • As shown beow, the missing data just shows nothing before it is entered, then the data and time shows as below on that form
Screenshot_20260123-235403 Screenshot_20260123-235441

Related Issue

Fixes https://github.com/Omo-Valley-Research-Project/AnthroCollect/issues/34

@najuna-brian najuna-brian changed the title Fix handlebars template syntax in labels feat: Fix handlebars template syntax in labels Jan 23, 2026
Copy link
Contributor

@Mishael-2584 Mishael-2584 left a comment

Choose a reason for hiding this comment

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

Looks good. Could we consider supporting nested paths if needed in the future?

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