From 9f3474d5df03011dd998ce09e34629f9c4a6c636 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 11 Oct 2011 11:39:42 -0500 Subject: [PATCH] Make JST namespace configurable --- lib/sprockets/jst_processor.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/sprockets/jst_processor.rb b/lib/sprockets/jst_processor.rb index 589085a46..5fe123c95 100644 --- a/lib/sprockets/jst_processor.rb +++ b/lib/sprockets/jst_processor.rb @@ -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