@@ -111,15 +111,20 @@ def children
111111
112112 private
113113
114- MULTI_VALUE_KEYWORDS = %w[ options accept ] . freeze
114+ MULTI_VALUE_KEYWORDS = [ ' options' , ' accept' ] . freeze
115115
116116 def build_metadata_json ( context , default_val )
117117 parts = [ ]
118118 parts << "\" type\" :#{ json_encode ( @inferred_type ) } "
119119 parts << "\" default\" :#{ json_encode ( default_val ) } "
120120
121+ if context . template_name
122+ parts << "\" template\" :#{ json_encode ( context . template_name ) } "
123+ end
124+
121125 @attributes . each do |key , expr |
122126 next if key == "type"
127+
123128 parts << "#{ json_encode ( key ) } :#{ json_encode ( context . evaluate ( expr ) ) } "
124129 end
125130
@@ -158,7 +163,7 @@ def lax_parse_keywords(remaining)
158163 if remaining =~ /\A ,\s */
159164 after_comma = Regexp . last_match . post_match
160165 # If next token after comma is a keyword: pattern, stop consuming values
161- if after_comma =~ /\A (\w [\w -]*)\s *:/
166+ if /\A (\w [\w -]*)\s *:/ . match? ( after_comma )
162167 remaining = after_comma
163168 break
164169 else
@@ -173,12 +178,10 @@ def lax_parse_keywords(remaining)
173178 else
174179 @accept_list = values
175180 end
176- else
177- if remaining =~ /\A (#{ QuotedFragment } )/o
178- @attributes [ key ] = parse_expression ( Regexp . last_match ( 1 ) )
179- remaining = Regexp . last_match . post_match . strip
180- remaining = remaining . sub ( /\A ,\s */ , '' )
181- end
181+ elsif remaining =~ /\A (#{ QuotedFragment } )/o
182+ @attributes [ key ] = parse_expression ( Regexp . last_match ( 1 ) )
183+ remaining = Regexp . last_match . post_match . strip
184+ remaining = remaining . sub ( /\A ,\s */ , '' )
182185 end
183186 end
184187 end
0 commit comments