def rezero_bindings(html, bindings)
      @@base_binding_id ||= 20_000
      # rezero
      parts  = html.split(/(\<\!\-\- \$\/?[0-9]+ \-\-\>)/).reject { |v| v == '' }

      new_html = []
      new_bindings = {}
      id_map = {}

      parts.each do |part|
        case part
          when /\<\!\-\- \$[0-9]+ \-\-\>/
            # Open
            binding_id = part.match(/\<\!\-\- \$([0-9]+) \-\-\>/)[1].to_i
            binding = bindings[binding_id]
            new_bindings[@@base_binding_id] = binding if binding

            new_html << "<!-- $#{@@base_binding_id} -->"
            id_map[binding_id] = @@base_binding_id
            @@base_binding_id += 1
          when /\<\!\-\- \$\/[0-9]+ \-\-\>/
            # Close
            binding_id = part.match(/\<\!\-\- \$\/([0-9]+) \-\-\>/)[1].to_i
            new_html << "<!-- $/#{id_map[binding_id]} -->"
          else
            # html string
            new_html << part
        end
      end

      # Also copy the attribute bindings
      bindings.each_pair do |name, binding|
        if name.is_a?(String) && name[0..1] == 'id'
          new_bindings[name] = binding
        end
      end

      return new_html.join(''), new_bindings
    end
def rezero_bindings(html, bindings)
      @@base_binding_id ||= 20_000
      # rezero
      parts  = html.split(/(\<\!\-\- \$\/?[0-9]+ \-\-\>)/).reject { |v| v == '' }

      new_html = []
      new_bindings = {}
      id_map = {}

      parts.each do |part|
        case part
          when /\<\!\-\- \$[0-9]+ \-\-\>/
            # Open
            binding_id = part.match(/\<\!\-\- \$([0-9]+) \-\-\>/)[1].to_i
            binding = bindings[binding_id]
            new_bindings[@@base_binding_id] = binding if binding

            new_html << "<!-- $#{@@base_binding_id} -->"
            id_map[binding_id] = @@base_binding_id
            @@base_binding_id += 1
          when /\<\!\-\- \$\/[0-9]+ \-\-\>/
            # Close
            binding_id = part.match(/\<\!\-\- \$\/([0-9]+) \-\-\>/)[1].to_i
            new_html << "<!-- $/#{id_map[binding_id]} -->"
          else
            # html string
            new_html << part
        end
      end

      # Also copy the attribute bindings
      bindings.each_pair do |name, binding|
        if name.is_a?(String) && name[0..1] == 'id'
          new_bindings[name] = binding
        end
      end

      return new_html.join(''), new_bindings
    end
When using bindings, we have to change the binding id so we don't reuse
 the same id when rendering a binding multiple times.