set template_root for dust template using jasmine.yml
This commit is contained in:
parent
aa40010fbd
commit
bf60c276b9
@ -4,33 +4,27 @@ require 'fileutils'
|
|||||||
|
|
||||||
module Jasmine
|
module Jasmine
|
||||||
module Headless
|
module Headless
|
||||||
|
|
||||||
class DustCache < CacheableAction
|
class DustCache < CacheableAction
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def cache_type
|
def cache_type
|
||||||
"dust"
|
"dust"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
def action
|
def action
|
||||||
template_root = "app/assets/javascripts/templates/"
|
@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 != '/'
|
||||||
template_name = file.split(template_root).last.split('.',2).first
|
template_name = file.split(template_root).last.split('.',2).first
|
||||||
Source.context.call("dust.compile", File.read(file), template_name)
|
@context.call("dust.compile", File.read(file), template_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,15 @@ module Jasmine::Headless
|
|||||||
class DustTemplate < Tilt::Template
|
class DustTemplate < Tilt::Template
|
||||||
include Jasmine::Headless::FileChecker
|
include Jasmine::Headless::FileChecker
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def template_root=(root)
|
||||||
|
@template_root = root
|
||||||
|
end
|
||||||
|
def template_root
|
||||||
|
@template_root || "app/assets/javascripts/templates/"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self.default_mime_type = 'application/javascript'
|
self.default_mime_type = 'application/javascript'
|
||||||
|
|
||||||
def prepare; end
|
def prepare; end
|
||||||
|
@ -225,6 +225,9 @@ module Jasmine::Headless
|
|||||||
add_files(@searches[type] = data.flatten, type, send(SEARCH_ROOTS[type]))
|
add_files(@searches[type] = data.flatten, type, send(SEARCH_ROOTS[type]))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# config dust template
|
||||||
|
Jasmine::Headless::DustTemplate.template_root = @config['template_dir']
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_files(patterns, type, dirs)
|
def add_files(patterns, type, dirs)
|
||||||
|
Loading…
Reference in New Issue
Block a user