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

custom braces as string, not char - {{ }} << >> #24

Open
Planche95 opened this issue Feb 2, 2021 · 2 comments
Open

custom braces as string, not char - {{ }} << >> #24

Planche95 opened this issue Feb 2, 2021 · 2 comments

Comments

@Planche95
Copy link

Hi, is it possible to use string as braces not char? Like {{ }} << >>? Using only one character is risky, you can end up with unwanted parameters.

@crozone
Copy link
Owner

crozone commented Feb 2, 2021

Passing strings as the brace parameter is not supported. This is because the library is hardcoded to assume that a pair of either brace character is an escaped brace, and strings do not conform nicely to this pattern.

For example, if the brace characters are '{' and '}', they are escaped using "{{" "}}". There is no ambiguity because all literal braces should be escaped before the string is parsed. An input such as "{{{param}}}" will be correctly parsed as "{" + param + "}".

I'm interested in the scenario where multi-character braces is required. If we were to allow "{{" and "}}" as the braces, how should they be escaped without introducing ambiguities?

@Planche95
Copy link
Author

Hi sorry for the late response.

I was looking at different libraries that will give me the possibility to parametrize jsons. I use to use handlebars for it https://github.com/Handlebars-Net/Handlebars.Net, but it doesn't have build in functionality to get all parameter names from file. In handlebars, default braces are "{{", "}}", and if you want to escape them you just add "" before them, like "{{".

In my case where I have json with random strings in it it's hard to choose only one brace, for example:

{
  "random" : "{asd<f(v)vvbm>lkk}",
  "random2" : "asda)>}xc"
}

I feel there is too much probability that "one char" open and close braces will be generated in my random strings and then I will end up with not wanted parameters. If I would use string as braces it would lower this probality. I'm not saying one brace is bad, but how should I handle this situation then?

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

No branches or pull requests

2 participants