Class: LispRailsView::LispHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/lisp-rails-view.rb

Constant Summary collapse

LISP =
File.expand_path('../../lisp/lisp-rails-view.lisp', __FILE__)

Class Method Summary collapse

Class Method Details

.call(template) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/lisp-rails-view.rb', line 16

def self.call(template)
  file = template.identifier
  x = `LANG=ja_JP.UTF-8 sbcl --script #{LISP} #{file}`
  code = <<EOT
[].tap do |b__|
def b__.push(x)
  if x.is_a?(Array)
x.map do |y|
  push(y)
end
  else
super(x.html_safe? ? x : ERB::Util.h(x))
  end
end
#{x}
end.flatten
EOT
  Rails.logger.debug('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
  Rails.logger.debug(code)
  Rails.logger.debug('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
  code
end