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

Version Path
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
sprockets-2.7.1 lib/sprockets/jst_processor.rb
sprockets-2.6.1 lib/sprockets/jst_processor.rb
sprockets-2.5.1 lib/sprockets/jst_processor.rb
sprockets-2.4.6 lib/sprockets/jst_processor.rb
sprockets-2.3.3 lib/sprockets/jst_processor.rb
sprockets-2.2.3 lib/sprockets/jst_processor.rb
sprockets-2.1.4 lib/sprockets/jst_processor.rb
sprockets-2.0.5 lib/sprockets/jst_processor.rb
swipe-rails-0.0.5 vendor/bundle/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
font-awesome-rails-3.1.1.2 vendor/ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
font-awesome-rails-3.1.1.1 vendor/ruby/2.0.0/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb
challah-1.0.0.beta3 vendor/bundle/gems/sprockets-2.2.2/lib/sprockets/jst_processor.rb