From d6e14acbe65fbca150d0b6c810f517726db2368d Mon Sep 17 00:00:00 2001 From: Iazel Date: Sat, 6 May 2017 19:06:10 +0200 Subject: [PATCH] Quotes string starting with a dot To understand why we want to do this, please refer to this issue on ktmpl repository (a way to have templates for kubernetes): https://github.com/InQuicker/ktmpl/issues/15 The problem applies only to string used as keys, but given that the emitters right now doesn't differentiate the two cases for string, I think is better to do it also for values instead of introducing branching and/or flag variables (can't think of cleaner solution for now). --- saphyr/src/emitter.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/saphyr/src/emitter.rs b/saphyr/src/emitter.rs index 9cd6a2d..51366e8 100644 --- a/saphyr/src/emitter.rs +++ b/saphyr/src/emitter.rs @@ -271,6 +271,7 @@ fn need_quotes(string: &str) -> bool { || string == "false" || string == "null" || string == "~" + || string.starts_with('.') || string.parse::().is_ok() || string.parse::().is_ok() } @@ -374,6 +375,8 @@ products: amount: 4 "*cookies": amount: 4 + ".milk": + amount: 1 "2.4": real key "[1,2,3,4]": array key "true": bool key