Class: Converter
- Inherits:
-
Object
- Object
- Converter
- Defined in:
- lib/converters.rb
Class Method Summary collapse
- .convert_selection(editor) ⇒ Object
- .convert_to_haml(html) ⇒ Object
- .convert_to_sass(css) ⇒ Object
- .convert_to_scss(css) ⇒ Object
Class Method Details
.convert_selection(editor) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/converters.rb', line 27 def self.convert_selection editor if editor.has_selection? text = editor.selection s_start = editor.selection_start changed_text = yield(text) editor.replace_selection_text(changed_text) # restore selection editor.select(s_start, s_start + changed_text.length) # # TODO: probably restore caret position # editor.move_caret -3 end end |
.convert_to_haml(html) ⇒ Object
43 44 45 |
# File 'lib/converters.rb', line 43 def self.convert_to_haml(html) Haml::HTML.new(html, :erb => true, :xhtml => true).render end |
.convert_to_sass(css) ⇒ Object
47 48 49 |
# File 'lib/converters.rb', line 47 def self.convert_to_sass(css) Sass::CSS.new(css).render(:sass) end |
.convert_to_scss(css) ⇒ Object
51 52 53 |
# File 'lib/converters.rb', line 51 def self.convert_to_scss(css) Sass::CSS.new(css).render(:scss) end |