Skip to content

Commit

Permalink
Make JST namespace configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Oct 11, 2011
1 parent 9483f5d commit 9f3474d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/sprockets/jst_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ def self.default_mime_type
'application/javascript'
end

def self.default_namespace
'this.JST'
end

def prepare
@namespace = self.class.default_namespace
end

attr_reader :namespace

def evaluate(scope, locals, &block)
<<-JST
(function() {
this.JST || (this.JST = {});
this.JST[#{scope.logical_path.inspect}] = #{indent(data)};
#{namespace} || (#{namespace} = {});
#{namespace}[#{scope.logical_path.inspect}] = #{indent(data)};
}).call(this);
JST
end
Expand Down

0 comments on commit 9f3474d

Please # to comment.