Class: JsTextRails::SvgTransformer
- Inherits:
-
TextTransformer
- Object
- TextTransformer
- JsTextRails::SvgTransformer
- Defined in:
- lib/js-text-rails/svg_transformer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #sanitize_js_string(text) ⇒ Object
-
#strip_xml_declaration(text) ⇒ Object
Strips <?xml …?> declarations so that external SVG and XML documents can be added to a document without worry.
Methods inherited from TextTransformer
#escape_js_string, #initialize, #transform
Constructor Details
This class inherits a constructor from JsTextRails::TextTransformer
Class Method Details
.default_namespace ⇒ Object
5 6 7 |
# File 'lib/js-text-rails/svg_transformer.rb', line 5 def self.default_namespace 'this.SVG' end |
Instance Method Details
#sanitize_js_string(text) ⇒ Object
9 10 11 12 13 |
# File 'lib/js-text-rails/svg_transformer.rb', line 9 def sanitize_js_string(text) text = strip_xml_declaration(text) text = escape_js_string(text) text end |
#strip_xml_declaration(text) ⇒ Object
Strips <?xml …?> declarations so that external SVG and XML documents can be added to a document without worry.
17 18 19 |
# File 'lib/js-text-rails/svg_transformer.rb', line 17 def strip_xml_declaration(text) text.gsub(/^\s*<\?xml.*?\?>\s*/im, '') end |