Class: FastHaml::TextCompiler
- Inherits:
-
Object
- Object
- FastHaml::TextCompiler
- Defined in:
- lib/fast_haml/text_compiler.rb
Defined Under Namespace
Classes: InvalidInterpolation
Constant Summary collapse
- INTERPOLATION_BEGIN =
/(\\*)(#[\{$@])/o
Class Method Summary collapse
Instance Method Summary collapse
- #compile(text, escape_html: @escape_html) ⇒ Object
-
#initialize(escape_html: true) ⇒ TextCompiler
constructor
A new instance of TextCompiler.
Constructor Details
#initialize(escape_html: true) ⇒ TextCompiler
Returns a new instance of TextCompiler.
9 10 11 |
# File 'lib/fast_haml/text_compiler.rb', line 9 def initialize(escape_html: true) @escape_html = escape_html end |
Class Method Details
.contains_interpolation?(text) ⇒ Boolean
23 24 25 |
# File 'lib/fast_haml/text_compiler.rb', line 23 def self.contains_interpolation?(text) INTERPOLATION_BEGIN === text end |
Instance Method Details
#compile(text, escape_html: @escape_html) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/fast_haml/text_compiler.rb', line 13 def compile(text, escape_html: @escape_html) if self.class.contains_interpolation?(text) compile_interpolation(text, escape_html: escape_html) else [:static, text] end end |