D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
td-agent
/
embedded
/
lib
/
ruby
/
gems
/
2.1.0
/
gems
/
sprockets-2.12.4
/
lib
/
sprockets
/
Filename :
jst_processor.rb
back
Copy
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