diff --git a/tpl/macro.twig b/tpl/macro.twig index 2ead37b..1130e30 100644 --- a/tpl/macro.twig +++ b/tpl/macro.twig @@ -122,25 +122,25 @@ func (self *{{o.name}}) WriteFields(writer meta.Writer) error { {% macro props_map(tokens) %} map[string]string{ -{% for k,v in tokens %} +{%- for k,v in tokens -%} "{{k}}" : "{{v|replace({'"' : '\\"'})}}", -{%- endfor ~%} +{%- endfor -%} } {% endmacro %} {% macro struct_fields_names(o) %} []string{ -{% for f in get_all_fields(o) ~%} +{%- for f in get_all_fields(o) -%} "{{f.name}}", -{%- endfor ~%} +{%- endfor -%} } {% endmacro %} {% macro struct_fields_props(o) %} map[string]map[string]string{ -{% for f in get_all_fields(o) ~%} +{%- for f in get_all_fields(o) -%} "{{f.name|ucfirst}}" : {{_self.props_map(f.tokens)}}, -{%- endfor ~%} +{%- endfor -%} } {% endmacro %} @@ -192,8 +192,8 @@ self.fieldsMask = meta.FieldsMask{} return err } - if _cont_size < {{o.fields|length - count_optional(o.fields)}} { - _cont_size = {{o.fields|length - count_optional(o.fields)}} + if _cont_size < {{(o.fields|length) - count_optional(o.fields)}} { + _cont_size = {{(o.fields|length) - count_optional(o.fields)}} } {%- if o.parent ~%} @@ -373,13 +373,13 @@ func New{{o.name}}ByName(name string) ({{o.name}}, error) { {% endmacro %} {% macro enum_values_list(o) %} -{%- for v in o.values|sort ~%} +{%- for v in o.values|sort -%} {{v}}, {%- endfor ~%} {% endmacro %} {% macro enum_values_map(o) %} -{%- for k,v in o.values ~%} +{%- for k,v in o.values -%} "{{k}}" : {{v}}, {%- endfor ~%} {% endmacro %}