Skip to content

docs: explain inline template expression detection - #201

Open
pralav-25 wants to merge 2 commits into
operaton:mainfrom
pralav-25:docs/inline-template-expression-168
Open

pralav-25 wants to merge 2 commits into
operaton:mainfrom
pralav-25:docs/inline-template-expression-168

Conversation

@pralav-25

@pralav-25 pralav-25 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Inline script content starting with ${ or #{ can be interpreted as a dynamic script-source expression before the selected script or template engine evaluates it. Document the rule for script tasks, listeners, conditions, and input/output parameters, link the existing script-source reference, and show the escaped FreeMarker comment workaround alongside the external-resource alternative.

The caution explains the error symptom and starts the example comment immediately after the opening script tag, avoiding an extra leading output newline.

Fixes #168.

Validation: npm run typecheck, npm run build, and git diff --check passed. Docusaurus reported broken-link and anchor warnings elsewhere in the documentation. Tests were not run.

</bpmn2:serviceTask>
```

For inline scripts in an input parameter, template engines other than JUEL are subject to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
For inline scripts in an input parameter, template engines other than JUEL are subject to
For inline scripts template engines other than JUEL are subject to

This will be true for all usages of inline scripts

dynamic script-source detection: if the script content starts with `${` or `#{` after
leading and trailing whitespace is trimmed, Operaton treats it as an expression that resolves
to a script source.
If those characters are part of the template itself, prefix the content with a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add empty line to separate the paragraph

@kthoms kthoms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, this addresses #168 well. The detection rule (trimmed, starts with ${ or #{, non-JUEL languages only) matches StringUtil.isExpression / ScriptUtil.isDynamicScriptExpression, the external-resource alternative is accurate (only the resource attribute value is checked, not the loaded file), the XML escaping is correct, and all MDX-sensitive characters are inside code. One wording issue that should be fixed, plus a few optional suggestions inline.

Possible follow-up (out of scope here): add a matching note to the "Script Source" section of scripting.md, which is the canonical place for the dynamic-source rule.

</bpmn2:serviceTask>
```

For inline scripts in an input parameter, template engines other than JUEL are subject to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should fix: this understates the scope. ScriptUtil.getScriptFormSource applies the check to every inline script source, not just input parameters: script tasks, execution/task listeners, conditions, and input and output parameters all go through it. A FreeMarker <scriptTask> whose body starts with ${ fails the same way.

Suggestion:

Suggested change
For inline scripts in an input parameter, template engines other than JUEL are subject to
For inline script sources (script tasks, listeners, conditions, and input/output parameters), template engines other than JUEL are subject to

Consider also linking the existing [script-source] reference so readers see the documented feature behind this behavior.

Comment on lines +148 to +154
For inline scripts in an input parameter, template engines other than JUEL are subject to
dynamic script-source detection: if the script content starts with `${` or `#{` after
leading and trailing whitespace is trimmed, Operaton treats it as an expression that resolves
to a script source.
If those characters are part of the template itself, prefix the content with a comment
recognized by the template engine, or use an external resource instead. For example, an
inline FreeMarker template can start with an escaped FreeMarker comment:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional:

  • Mention the symptom, e.g. that the template is never passed to the template engine and the content is evaluated as an expression instead, which usually fails or produces unexpected output. Users tend to search by symptom.
  • Since this is a pitfall, a :::caution (or :::note, as used elsewhere on this page) admonition would make it stand out.
  • Strictly, the check applies to any non-JUEL language (Groovy, JavaScript, ...), not only template engines. Fine on a templating page, but "script or template languages other than JUEL" would be more precise.

```xml
<operaton:inputParameter name="message">
<operaton:script scriptFormat="freemarker">
&lt;#-- Keep this as an inline FreeMarker template. --&gt;${name} likes:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional: only the detection check trims the source; the template itself is not trimmed. The rendered output will therefore start with a newline and keep the indentation on each line. Placing the comment directly after <operaton:script ...> (as in the issue) avoids the leading newline, or a short note could mention it.

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.

Add to Templating Engine Docs: InputParameter inline-scripts using templating engines fail to resolve when starting with ${ or #{

2 participants