support dust template
This commit is contained in:
parent
282ed40264
commit
72b0c80b48
41
lib/jasmine/headless/dust_template.rb
Normal file
41
lib/jasmine/headless/dust_template.rb
Normal file
@ -0,0 +1,41 @@
|
||||
require 'tilt/template'
|
||||
require 'execjs'
|
||||
|
||||
module Jasmine::Headless
|
||||
class DustTemplate < Tilt::Template
|
||||
include Jasmine::Headless::FileChecker
|
||||
|
||||
module Source
|
||||
def self.path
|
||||
@path ||= File.expand_path('../../../vendor/assets/javascripts/dust-full-for-compile.js', __FILE__)
|
||||
end
|
||||
|
||||
def self.contents
|
||||
@contents ||= File.read(path)
|
||||
end
|
||||
|
||||
def self.context
|
||||
@context ||= ExecJS.compile(contents)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class DustTemplate < ::Tilt::Template
|
||||
|
||||
def self.default_mime_type
|
||||
'application/javascript'
|
||||
end
|
||||
|
||||
def prepare
|
||||
end
|
||||
|
||||
def evaluate(scope, locals, &block)
|
||||
template_root = Dust.config.template_root
|
||||
template_name = file.split(template_root).last.split('.',2).first
|
||||
Source.context.call("dust.compile", data, template_name)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -66,6 +66,7 @@ module Jasmine::Headless
|
||||
register_engine '.js', Jasmine::Headless::JSTemplate
|
||||
register_engine '.css', Jasmine::Headless::CSSTemplate
|
||||
register_engine '.jst', Jasmine::Headless::JSTTemplate
|
||||
register_engine '.dust', Jasmine::Headless::DustTemplate
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
'hello'
|
3209
vendor/assets/javascripts/dust-full-for-compile.js
vendored
Normal file
3209
vendor/assets/javascripts/dust-full-for-compile.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user