Class: ActionviewPrecompiler::TemplateParser
- Inherits:
-
Object
- Object
- ActionviewPrecompiler::TemplateParser
- Defined in:
- lib/actionview_precompiler/template_parser.rb
Defined Under Namespace
Classes: FakeTemplate
Instance Attribute Summary collapse
-
#basename ⇒ Object
readonly
Returns the value of attribute basename.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
Instance Method Summary collapse
-
#initialize(filename) ⇒ TemplateParser
constructor
A new instance of TemplateParser.
- #render_calls ⇒ Object
Constructor Details
#initialize(filename) ⇒ TemplateParser
Returns a new instance of TemplateParser.
21 22 23 24 25 26 |
# File 'lib/actionview_precompiler/template_parser.rb', line 21 def initialize(filename) @filename = filename @basename = File.basename(filename) handler_ext = @basename.split(".").last @handler = HANDLERS_FOR_EXTENSION[handler_ext] end |
Instance Attribute Details
#basename ⇒ Object (readonly)
Returns the value of attribute basename.
5 6 7 |
# File 'lib/actionview_precompiler/template_parser.rb', line 5 def basename @basename end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/actionview_precompiler/template_parser.rb', line 5 def filename @filename end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
5 6 7 |
# File 'lib/actionview_precompiler/template_parser.rb', line 5 def handler @handler end |
Instance Method Details
#render_calls ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/actionview_precompiler/template_parser.rb', line 28 def render_calls src = File.read(@filename) if src.include?("render") compiled_source = @handler.call(FakeTemplate.new, File.read(@filename)) compiled_source = "def _template; #{compiled_source}; end" RenderParser.new(compiled_source).render_calls else [] end end |