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.
10 11 12 |
# File 'lib/faml/text_compiler.rb', line 10 def initialize(escape_html: true) @escape_html = escape_html end |
Class Method Details
.contains_interpolation?(text) ⇒ Boolean
24 25 26 |
# File 'lib/faml/text_compiler.rb', line 24 def self.contains_interpolation?(text) INTERPOLATION_BEGIN === text end |
Instance Method Details
#compile(text, lineno, escape_html: @escape_html) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/faml/text_compiler.rb', line 14 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 |