Class: Emcee::DirectiveProcessor
- Inherits:
-
Sprockets::DirectiveProcessor
- Object
- Sprockets::DirectiveProcessor
- Emcee::DirectiveProcessor
- Defined in:
- lib/emcee/directive_processor.rb
Overview
The ‘DirectiveProcessor` is responsible for parsing and evaluating directive comments in a source file.
Constant Summary collapse
- HEADER_PATTERN =
Matches the entire header/directive block. This is everything from the top of the file, enclosed in html comments.
/\A((?m:\s*)(<!--(?m:.*?)-->))+/
Instance Method Summary collapse
-
#render(context, locals) ⇒ Object
Implement ‘render` so that it uses our own header pattern.
Instance Method Details
#render(context, locals) ⇒ Object
Implement ‘render` so that it uses our own header pattern.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/emcee/directive_processor.rb', line 10 def render(context, locals) @context = context @pathname = context.pathname @directory = File.dirname(@pathname) @header = data[HEADER_PATTERN, 0] || "" @body = $' || data # Ensure body ends in a new line @body += "\n" if @body != "" && @body !~ /\n\Z/m @included_pathnames = [] @result = "" @result.force_encoding(body.encoding) @has_written_body = false process_directives process_source @result end |