Skip to content
Browse files

Remove template#file

  • Loading branch information...
1 parent 6199931 commit 3d00def9a2e08d835844341afb84b5d0af855975 @josh josh committed Dec 18, 2013
View
7 lib/sprockets/directive_processor.rb
@@ -74,8 +74,7 @@ class DirectiveProcessor < Template
# for the complete API.
def render(context)
@context = context
-
- @pathname = Pathname.new(file)
+ @pathname = context.pathname
@header = data[HEADER_PATTERN, 0] || ""
@body = $' || data
@@ -250,7 +249,7 @@ def process_require_directory_directive(path = ".")
entries(root).each do |pathname|
pathname = root.join(pathname)
- if pathname.to_s == self.file
+ if pathname.to_s == self.pathname.to_s
next
elsif context.asset_requirable?(pathname)
context.require_asset(pathname)
@@ -279,7 +278,7 @@ def process_require_tree_directive(path = ".")
required_paths = []
context.environment.recursive_stat(root) do |pathname, stat|
- if pathname.to_s == self.file
+ if pathname.to_s == self.pathname.to_s
next
elsif stat.directory?
context.depend_on(pathname)
View
2 lib/sprockets/erb_template.rb
@@ -12,7 +12,7 @@ def render(context)
engine = ::ERB.new(data, nil, '<>')
method_name = "__sprockets_#{Thread.current.object_id.abs}"
klass = (class << context; self; end)
- engine.def_method(klass, method_name, file)
+ engine.def_method(klass, method_name, context.pathname.to_s)
context.send(method_name)
end
end
View
2 lib/sprockets/less_template.rb
@@ -14,7 +14,7 @@ def render(context)
if ::Less.const_defined? :Engine
engine = ::Less::Engine.new(data)
else
- parser = ::Less::Parser.new(:filename => file)
+ parser = ::Less::Parser.new(:filename => context.pathname.to_s)
engine = parser.parse(data)
end
View
2 lib/sprockets/sass_template.rb
@@ -29,7 +29,7 @@ def render(context)
cache_store = SassCacheStore.new(context.environment)
options = {
- :filename => file,
+ :filename => context.pathname.to_s,
:syntax => syntax,
:cache_store => cache_store,
:importer => SassImporter.new(context, context.pathname),
View
4 lib/sprockets/template.rb
@@ -1,6 +1,6 @@
module Sprockets
class Template
- attr_reader :data, :file
+ attr_reader :data
@engine_initialized = false
class << self
@@ -11,8 +11,6 @@ class << self
end
def initialize(file, &block)
- @file = file
-
if !self.class.engine_initialized?
initialize_engine if respond_to?(:initialize_engine)
self.class.engine_initialized = true

0 comments on commit 3d00def

Please sign in to comment.
Something went wrong with that request. Please try again.