2011-11-22 15:36:42 +00:00
|
|
|
require 'tilt/template'
|
|
|
|
|
|
|
|
module Jasmine::Headless
|
|
|
|
class JSTemplate < Tilt::Template
|
2011-12-05 23:49:52 +00:00
|
|
|
include Jasmine::Headless::FileChecker
|
2011-11-22 15:36:42 +00:00
|
|
|
self.default_mime_type = 'application/javascript'
|
|
|
|
|
|
|
|
def prepare ; end
|
|
|
|
|
|
|
|
def evaluate(scope, locals, &block)
|
2011-12-05 23:49:52 +00:00
|
|
|
if bad_format?(file)
|
|
|
|
alert_bad_format(file)
|
|
|
|
return ''
|
|
|
|
end
|
2011-11-29 15:56:02 +00:00
|
|
|
if data[%r{^<script type="text/javascript"}]
|
2011-11-22 17:14:00 +00:00
|
|
|
data
|
|
|
|
else
|
|
|
|
file ? %{<script type="text/javascript" src="#{file}"></script>} : data
|
|
|
|
end
|
2011-11-22 15:36:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|