Sha256: b852f04426dacc5176ca6ea73500371bd128d433d1614262559c48db3bc9124b
Contents?: true
Size: 606 Bytes
Versions: 126
Compression:
Stored size: 606 Bytes
Contents
require 'tilt' module Sprockets class JstProcessor < Tilt::Template 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() { #{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
Version data entries
126 entries across 101 versions & 18 rubygems