jasmine-headless-webkit/lib/jasmine/headless/dust_template.rb

42 lines
882 B
Ruby
Raw Normal View History

2012-01-11 18:23:39 +00:00
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