Class: Fmt::TemplateParser
- Defined in:
- lib/fmt/parsers/template_parser.rb
Overview
Parses a template from a string and builds an AST (Abstract Syntax Tree)
Constant Summary collapse
- EMBED_PEEK =
: Regexp – detects start of an embed prefix (look ahead)
%r{(?=#{esc Sigils::EMBED_PREFIX})}ou- PIPELINE_PEEK =
: Regexp – detects start of a pipeline (look ahead)
%r{(?=[#{Sigils::FORMAT_PREFIX}][^#{Sigils::FORMAT_PREFIX}])}ou- PERCENT_LITERAL =
: Regexp – detects a percent literal
%r{[#{Sigils::FORMAT_PREFIX}]{2}}ou- WHITESPACE =
: Regexp – detects whitespace
%r{\s}ou
Constants inherited from Parser
Instance Attribute Summary collapse
-
#urtext ⇒ Object
readonly
: String – original source code.
Instance Method Summary collapse
-
#initialize(urtext = "") ⇒ TemplateParser
constructor
Constructor.
-
#parse ⇒ Object
Parses the urtext (original source code).
Methods inherited from Parser
Constructor Details
#initialize(urtext = "") ⇒ TemplateParser
Constructor
15 16 17 |
# File 'lib/fmt/parsers/template_parser.rb', line 15 def initialize(urtext = "") @urtext = urtext.to_s.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "?") end |
Instance Attribute Details
#urtext ⇒ Object (readonly)
: String – original source code
19 20 21 |
# File 'lib/fmt/parsers/template_parser.rb', line 19 def urtext @urtext end |
Instance Method Details
#parse ⇒ Object
Parses the urtext (original source code)
23 24 25 |
# File 'lib/fmt/parsers/template_parser.rb', line 23 def parse cache(urtext) { super } end |