Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (23 sloc) 0.586 kb
require 'tilt'
module Sprockets
class JstProcessor < Tilt::Template
self.default_mime_type = 'application/javascript'
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() { #{namespace} || (#{namespace} = {}); #{namespace}[#{scope.logical_path.inspect}] = #{indent(data)};
}).call(this);
JST
end
private
def indent(string)
string.gsub(/$(.)/m, "\\1 ").strip
end
end
end
Jump to Line
Something went wrong with that request. Please try again.