Skip to content

docs: document escapeJson helper in AI playground - #1128

Merged
JanCizmar merged 2 commits into
mainfrom
jancizmar/escape-json-prompt-helper
Jul 10, 2026
Merged

docs: document escapeJson helper in AI playground#1128
JanCizmar merged 2 commits into
mainfrom
jancizmar/escape-json-prompt-helper

Conversation

@JanCizmar

Copy link
Copy Markdown
Member

Documents the escapeJson Handlebars helper added in tolgee/tolgee-platform#3799 (fixes tolgee/tolgee-platform#3683).

What's added to platform/translation_process/ai_playground.mdx

  • A List of available helpers section, matching the existing "List of available variables" / "List of available fragments" structure.

  • A Building a structured prompt subsection with the JSON example the feature exists for:

    {
      "context": "{{escapeJson key.name}} {{escapeJson key.description}}",
      "text": "{{escapeJson source.translation}}",
      "locale": "{{target.languageTag}}"
    }
  • A note that escapeJson is safe on any variable (applying it to an already-escaped value returns it unchanged, so it never escapes twice).

  • A note that the output suits a JSON string or a double-quoted YAML scalar, but not single-quoted, plain or block scalars, where a backslash is literal.

  • The templating intro now mentions that the editor hints helpers alongside variables and fragments.

Note

Merge after tolgee/tolgee-platform#3799 ships, since the helper does not exist before then.

Adds a helpers section describing escapeJson, with an example of building a
structured JSON prompt and a note about which YAML scalar styles it suits.
@netlify

netlify Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploy Preview for tolgee-docs ready!

Name Link
🔨 Latest commit b5ac5b7
🔍 Latest deploy log https://app.netlify.com/projects/tolgee-docs/deploys/6a4feebc64007e000813db1b
😎 Deploy Preview https://deploy-preview-1128--tolgee-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

| .isCJK | Is Chinese, Japanese or Korean | false |


## List of available helpers

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Helpers should go to the end and the table doesn't have much sense when we have only one, so you can simply create a section just for escapeJson.

|------------|-----------------------------------------------------------------------------------------------------------------|------------------------------------|
| escapeJson | Escapes quotes, newlines and backslashes in the value, so it can be safely embedded inside a JSON string | \{\{escapeJson key.description}} |

### Building a structured prompt

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should go to end.


### Building a structured prompt

Some models expect a structured payload rather than prose. Without escaping, a key description that

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Models, usually don't but sometimes escaping can make sense as protection for prompt injection for example.

Moves the helper to the end of the page, drops the single-row table, and
corrects the motivation: models rarely need structured payloads, but escaping
guards a value from breaking out of its string.
@JanCizmar
JanCizmar merged commit b129fc1 into main Jul 10, 2026
6 checks passed
@JanCizmar
JanCizmar deleted the jancizmar/escape-json-prompt-helper branch July 10, 2026 06:35
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.

Provide escaped key descriptions and text as template variables in custom LLM prompts

1 participant