Huachao / vscode-restclient

REST Client Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
MIT License
5.31k stars 444 forks source link

How to escape handlebars expressions? #947

Open adriano-di-giovanni opened 2 years ago

adriano-di-giovanni commented 2 years ago

I have strings that contain handlebars expressions, as follows

POST /templates
Content-Type: application/json

{
  "text": "{{ping}}"
}

How do I escape {{ping}} to avoid restclient treating it as a variable?

Thanks

Huachao commented 2 years ago

@adriano-di-giovanni nice catch, it seems no work around for now, but if you don't define a variable named ping, the request body will still be as is.

adriano-di-giovanni commented 2 years ago

@Huachao, nope. The extension requires the variable to be defined. I escaped the handlebars extension as follows

POST /templates
Content-Type: application/json

{
  "text": "\u007b\u007bping\u007d\u007d"
}
Huachao commented 2 years ago

@adriano-di-giovanni If not defined, it just shows an error and won't break the outgoing request

vsnthdev commented 1 year ago

I'm also having to send Handlebars strings in my payload and VSCode says there's an error. Thanks @adriano-di-giovanni for a workaround, I'll be also doing the same until a proper solution is implemented.