Handlebars Templating Not Parsed in Details Block of Markdown Field

Description

In V2.2.17, on the V2 page, adding a Markdown field to a Details block and using Handlebars templating results in unexpected behavior.

There are two related issues:

1. Handlebars conditions are not parsed

Handlebars conditional expressions such as:

{{#if ctx.record.variable}}
  hello world
{{/if}}

are not evaluated.

For example, if ctx.record.variable is true, the expected behavior is for the Details block to display:

hello world

Instead, the entire Handlebars expression is displayed as literal text:

{{#if ctx.record.variable}} hello world {{/if}}

2. Adding Handlebars content breaks other field variables

Once Handlebars template content is added to the Markdown field, it also appears to break the variable rendering for the entire markdown field.

For example, if:

{{ctx.record.variableA}}

has a value of:

hello world

the expected result is:

hello world

However, after adding the Handlebars template content, it is rendered as literal text:

{{ctx.record.variableA}}

Expected Behavior

  • Handlebars expressions, including conditional helpers such as {{#if ...}}, should be properly parsed and evaluated in the Markdown field.
  • Regular variables such as {{ctx.record.variableA}} should continue to resolve to their corresponding values.

Actual Behavior

  • {{#if ...}} conditional expressions are displayed as literal text instead of being evaluated.
  • Adding Handlebars template content causes other {{ctx.record.variable}} expressions in the field to also render as literal text.

Thanks for the detailed report. On NocoBase V2 pages, the Markdown block and the Markdown field inside a Details block are rendered with the Liquid template engine, not Handlebars. That is why Handlebars conditionals like {{#if ctx.record.variable}}...{{/if}} are not evaluated and show up as literal text.

Please rewrite the template with Liquid syntax, for example:

{% if ctx.record.variable %}
hello world
{% endif %}

Plain interpolation keeps the same shape, for example {{ ctx.record.variableA }}. Liquid also supports {% else %}, {% elsif %}, {% for item in list %}...{% endfor %}, and filters.

For the second symptom: if a single variable such as {{ ctx.record.variableA }} renders correctly but the whole field turns into literal text once the {{#if ...}} block is added, the unsupported Handlebars tokens are breaking parsing. After switching to Liquid, please confirm whether both the condition and the other variables resolve correctly. If they still do not, send the exact Markdown field content and any browser console errors.

Reference: Markdown Block - NocoBase Documentation