Class: Faml::TextCompiler
- Inherits:
-
Object
- Object
- Faml::TextCompiler
- Defined in:
- lib/faml/text_compiler.rb
Defined Under Namespace
Classes: InvalidInterpolation
Constant Summary collapse
- INTERPOLATION_BEGIN =
/(\\*)(#[\{$@])/o
Class Method Summary collapse
Instance Method Summary collapse
- #compile(text, lineno, 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.
11 12 13 |
# File 'lib/faml/text_compiler.rb', line 11 def initialize(escape_html: true) @escape_html = escape_html end |
Class Method Details
.contains_interpolation?(text) ⇒ Boolean
25 26 27 |
# File 'lib/faml/text_compiler.rb', line 25 def self.contains_interpolation?(text) INTERPOLATION_BEGIN === text end |
Instance Method Details
#compile(text, lineno, escape_html: @escape_html) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/faml/text_compiler.rb', line 15 def compile(text, lineno, escape_html: @escape_html) if self.class.contains_interpolation?(text) compile_interpolation(text, lineno, escape_html: escape_html) else [:static, text] end end |