Sha256: 1ac37a8a231958dc99e3c2487b2d7583b278623f80cfd012162dd7b9bef54c34
Contents?: true
Size: 1017 Bytes
Versions: 1
Compression:
Stored size: 1017 Bytes
Contents
require "ejs-rcompiler" module Sprockets module Directives class TemplateDirective < RequireDirective def self.pattern /(template)\s+(#{ANGLED_STRING})/ end def evaluate_in(preprocessor) if template_file_path compile_ejs(template_file_path.to_s) super(preprocessor) else raise_load_error end end protected def compile_ejs(source_file) compiler = Ejs::Compiler.new compiler.compile(source_file, namespace) end def namespace dir = File.dirname(require_location) dir == "." ? nil : dir.gsub(/\//, ".") end def template_file_path @template_file_path ||= location_finder.find(normalize_template(require_location)) end def normalize_template(location) File.join(File.dirname(location), File.basename(location, ".ejs") + ".ejs") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sprockets-foo-0.0.4 | lib/sprockets/directives/template_directive.rb |