4 ms·
Why not just use quotes all the time for strings?
by raffraffraff 2y ago
Why not just use quotes all the time for strings?
- mystifyingpoi 2y agoI like that in concept, but 1) literally no one does that (prime example - Kubernetes docs) and 2) it looks much more messy with quotes, when you know that they are unnecessary in 95% of cases.
- zelphirkalt 2y agoOh, I did that in Ansible stuff. Using quotes for all strings. Exactly because I know what a mess YAML is.
- mystifyingpoi 2y agoFair enough. I'm tempted to try it. There should be probably a yamllint rule for this...
- kinow 2y agoI guess sometikes it is out of your control. I work on a workflow manager where users specify their workflows with YAML. So there's little we can do to prevent them from writing things like no, n, t in a place it could cause some issue like ij the article.
- zelphirkalt 2y agoAh, the many places that choose to use YAML for no good reason...
- kinow 2y agoYeah, can't say much about it as I joined after they had already decided on using YAML.
- kergonath 2y agoBecause that’s annoying. YAML is often written and read by humans. If you want a verbose and more regular way to do it, there is always JSON. But JSON is really annoying to deal with for humans, although it is much better than YAML for several applications.
- hnlmorg 2y agoYou don’t actually need quotes to define a string in YAML. Eg the following syntax User: Name: >- Bob Phone: >- 01234 56789 Description:>- This is a multi line description That’s both readable and parses your records as strings. Edit: This stack overflow like provides more details https://stackoverflow.com/questions/3790454/how-do-i-break-a-string-in-yaml-over-multiple-lines https://stackoverflow.com/questions/3790454/how-do-i-break-a...
- mdaniel 2y agoI can't tell if it's irony or not given the sentiment in this thread, but that is not a declaration of a multiline Description field, that's a field of User named "Description:>-" that happens to be missing its trailing ":" Seeing that used systemically, versus just for "risky" fields makes me want to draw attention to the fantastic remarshal tool[1], which offers a "--yaml-style >" (and "|" and the rest) which will render yaml fields quoted as one wishes 1: https://github.com/remarshal-project/remarshal#readme https://github.com/remarshal-project/remarshal#readme and/or $(brew install remarshal)
- hnlmorg 2y ago> I can't tell if it's irony or not given the sentiment in this thread, but that is not a declaration of a multiline Description field, that's a field of User named "Description:>-" that happens to be missing its trailing ":" The trailing ‘:’ was there right after the ‘n’. Examples of this syntax: https://github.com/lmorg/murex/blob/master/builtins/core/arraytools/2darray_doc.yaml https://github.com/lmorg/murex/blob/master/builtins/core/arr... I do agree it’s a bit of a kludge. But if you want data types and unquoted strings then anything you do to the syntax to denote strings over other data types then becomes a bit of a kludge. The one good thing about this kludge is it allows for string literals (ie no complicated escaping rules). > Seeing that used systemically, versus just for "risky" fields makes me want to draw attention to the fantastic remarshal tool[1], which offers a "--yaml-style >" (and "|" and the rest) which will render yaml fields quoted as one wishes I don’t really understand what you’re alluding to here.