Class: TypeScript::Rails::TemplateHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/typescript/rails/template_handler.rb

Class Method Summary collapse

Class Method Details

.call(template) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/typescript/rails/template_handler.rb', line 9

def call(template)
  compiled_source = erb_handler.call(template)
  path = template.identifier.gsub(/['\\]/, '\\\\\&') # "'" => "\\'", '\\' => '\\\\'
  <<-EOS
    ::TypeScript::Rails::Compiler.compile('#{path}', (begin;#{compiled_source};end))
  EOS
end

.erb_handlerObject



5
6
7
# File 'lib/typescript/rails/template_handler.rb', line 5

def erb_handler
  @erb_handler ||= ActionView::Template.registered_template_handler(:erb)
end