2012-01-11 20:36:43 +00:00
|
|
|
require 'execjs'
|
|
|
|
require 'digest/sha1'
|
|
|
|
require 'fileutils'
|
|
|
|
|
|
|
|
module Jasmine
|
|
|
|
module Headless
|
2012-01-12 06:47:39 +00:00
|
|
|
|
2012-01-11 20:36:43 +00:00
|
|
|
class DustCache < CacheableAction
|
2012-01-12 06:47:39 +00:00
|
|
|
|
2012-01-11 20:36:43 +00:00
|
|
|
class << self
|
|
|
|
def cache_type
|
|
|
|
"dust"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def action
|
2012-01-12 06:47:39 +00:00
|
|
|
@path ||= File.expand_path('../../../../vendor/assets/javascripts/dust-full-for-compile.js', __FILE__)
|
|
|
|
@contents ||= File.read(@path)
|
|
|
|
@context ||= ExecJS.compile(@contents)
|
|
|
|
|
|
|
|
template_root = DustTemplate.template_root
|
|
|
|
template_root = template_root + '/' if template_root[ template_root.length - 1 ].chr != '/'
|
2012-01-11 20:36:43 +00:00
|
|
|
template_name = file.split(template_root).last.split('.',2).first
|
2012-01-12 06:47:39 +00:00
|
|
|
@context.call("dust.compile", File.read(file), template_name)
|
2012-01-11 20:36:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-01-12 06:47:39 +00:00
|
|
|
|
|
|
|
|