diff --git a/src/codegen.inc.php b/src/codegen.inc.php index 505fe4d..e8321f9 100644 --- a/src/codegen.inc.php +++ b/src/codegen.inc.php @@ -56,6 +56,8 @@ function supported_tokens() 'default', 'virtual', + 'go_json_quote', + 'statist', 'statist_skip', 'statist_alias', @@ -330,6 +332,14 @@ function add_twig_filters(\Twig\Environment $twig) function(\mtgMetaField $field): string { $tag = get_field_alias_or_name($field); $type = $field->getType(); + + //NOTE: currently quoted by default + $quote = !$field->hasToken("go_json_quote") || + filter_var($field->getToken("go_json_quote"), FILTER_VALIDATE_BOOLEAN) === true; + + if(!$quote) + return $tag; + if($type instanceof \mtgMetaEnum || ($type instanceof \mtgBuiltinType && !$type->isString() && !$type->isBlob())) { return $tag.',string';