Class: PureScript::Rails::TemplateHandler

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

Class Method Summary collapse

Class Method Details

.call(template) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/purescript/rails/template_handler.rb', line 9

def self.call(template)
  compiled_source = erb_handler.call(template)
  Tempfile.open('purescript-', Rails.root.join('tmp')) do |f|
    begin
      f.write(compiled_source)
      f.flush
      output = `psc #{compiled_source} --main`
    ensure
      f.close
      f.unlink
    end
  end
  output
end

.erb_handlerObject



4
5
6
# File 'lib/purescript/rails/template_handler.rb', line 4

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