def _replace_options(string, options)
      # Unescape the string so we can use the returned string
      # to set an elements inner html.
      s = string.gsub('&lt;', '<').gsub('&gt;', '>')

      if options
        # But escape option values to prevent code injection
        s.gsub(/%\{(\w+)\}/) do |m|
          key = ($1 || m.tr("%{}", ""))

          if options.key?(key)
            options[key].to_s.gsub('<', '&lt;').gsub('>', '&gt;')
          else
            key
          end
        end
      else
        s
      end
    end
def _replace_options(string, options)
      # Unescape the string so we can use the returned string
      # to set an elements inner html.
      s = string.gsub('&lt;', '<').gsub('&gt;', '>')

      if options
        # But escape option values to prevent code injection
        s.gsub(/%\{(\w+)\}/) do |m|
          key = ($1 || m.tr("%{}", ""))

          if options.key?(key)
            options[key].to_s.gsub('<', '&lt;').gsub('>', '&gt;')
          else
            key
          end
        end
      else
        s
      end
    end
Internal method to substitute placeholders with a value.