Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add escape string helper #1166

Open
ondrejnebesky opened this issue Oct 19, 2023 · 0 comments
Open

Add escape string helper #1166

ondrejnebesky opened this issue Oct 19, 2023 · 0 comments
Labels
feature New feature request

Comments

@ondrejnebesky
Copy link

I could use new handlebars filter to escape any string, so I can use it in JSON templates. Currently, some inputs can break JSON formatting in the template. The following characters should be escaped:

  • Backspace to be replaced with \b
  • Form feed to be replaced with \f
  • Newline to be replaced with \n
  • Carriage return to be replaced with \r
  • Tab to be replaced with \t
  • Double quote to be replaced with "
  • Backslash to be replaced with \

Example

template:

{
  "body": "{{body 'Body'}}",
}

input: Body=Hello "World"
current output:

{
  "body": "Hello "World"",
}

expected output:

{
  "body": "Hello \"World\"",
}
@255kb 255kb added the feature New feature request label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

2 participants