class Sprockets::JstProcessor

Attributes

namespace[R]

Public Class Methods

default_namespace() click to toggle source
# File lib/sprockets/jst_processor.rb, line 7
def self.default_namespace
  'this.JST'
end

Public Instance Methods

evaluate(scope, locals, &block) click to toggle source
# File lib/sprockets/jst_processor.rb, line 17
    def evaluate(scope, locals, &block)
      <<-JST
(function() { #{namespace} || (#{namespace} = {}); #{namespace}[#{scope.logical_path.inspect}] = #{indent(data)};
}).call(this);
      JST
    end
prepare() click to toggle source
# File lib/sprockets/jst_processor.rb, line 11
def prepare
  @namespace = self.class.default_namespace
end

Private Instance Methods

indent(string) click to toggle source
# File lib/sprockets/jst_processor.rb, line 25
def indent(string)
  string.gsub(/$(.)/, "\\1  ").strip
end