support dust template

This commit is contained in:
Sungwon Lee 2012-01-12 03:23:39 +09:00
parent 282ed40264
commit 72b0c80b48
5 changed files with 3253 additions and 1 deletions

View File

@ -33,4 +33,4 @@ gem 'jquery-rails'
gem 'ejs' gem 'ejs'
gem 'simplecov' gem 'simplecov'
gem 'execjs'

View 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

View File

@ -66,6 +66,7 @@ module Jasmine::Headless
register_engine '.js', Jasmine::Headless::JSTemplate register_engine '.js', Jasmine::Headless::JSTemplate
register_engine '.css', Jasmine::Headless::CSSTemplate register_engine '.css', Jasmine::Headless::CSSTemplate
register_engine '.jst', Jasmine::Headless::JSTTemplate register_engine '.jst', Jasmine::Headless::JSTTemplate
register_engine '.dust', Jasmine::Headless::DustTemplate
end end
end end

View File

@ -0,0 +1 @@
'hello'

File diff suppressed because it is too large Load Diff