docs: document escapeJson helper in AI playground - #1128
Merged
Conversation
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.
✅ Deploy Preview for tolgee-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
JanCizmar
commented
Jul 9, 2026
| | .isCJK | Is Chinese, Japanese or Korean | false | | ||
|
|
||
|
|
||
| ## List of available helpers |
Member
Author
There was a problem hiding this comment.
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 |
|
|
||
| ### Building a structured prompt | ||
|
|
||
| Some models expect a structured payload rather than prose. Without escaping, a key description that |
Member
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents the
escapeJsonHandlebars helper added in tolgee/tolgee-platform#3799 (fixes tolgee/tolgee-platform#3683).What's added to
platform/translation_process/ai_playground.mdxA 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
escapeJsonis 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.