lib/faml/compiler.rb in faml-0.3.3 vs lib/faml/compiler.rb in faml-0.3.4

- old
+ new

@@ -316,16 +316,26 @@ def build_optimized_static_attributes(parser, static_id, static_class) static_attributes = {} parser.static_attributes.each do |k, v| static_attributes[k.to_s] = v end + + class_list = Array(static_attributes['class']).flat_map { |c| c.to_s.split(/ +/) } unless static_class.empty? - class_list = static_attributes.fetch('class', '').to_s.split(/ +/) - static_attributes['class'] = static_class.split(/ +/).concat(class_list).uniq.sort.join(' ') + class_list.concat(static_class.split(/ +/)) end + unless class_list.empty? + static_attributes['class'] = class_list.uniq.sort.join(' ') + end + + id_list = Array(static_attributes['id']) unless static_id.empty? - static_attributes['id'] = [static_id, static_attributes['id']].compact.join('_') + id_list = [static_id].concat(id_list) end + unless id_list.empty? + static_attributes['id'] = id_list.join('_') + end + static_attributes end def build_optimized_dynamic_attributes(parser, static_attributes) dynamic_attributes = {}