Sha256: e51351c8e39f5f49da07c5e4284670b4e686b30ec8bac2f151e5e3697526a52b

Contents?: true

Size: 749 Bytes

Versions: 157

Compression:

Stored size: 749 Bytes

Contents

require 'tilt'

module Sprockets
  # For JS developers who are colonfobic, concatenating JS files using
  # the module pattern usually leads to syntax errors.
  #
  # The `SafetyColons` processor will insert missing semicolons to the
  # end of the file.
  #
  # This behavior can be disabled with:
  #
  #     environment.unregister_postprocessor 'application/javascript', Sprockets::SafetyColons
  #
  class SafetyColons < Tilt::Template
    def prepare
    end

    def evaluate(context, locals, &block)
      # If the file is blank or ends in a semicolon, leave it as is
      if data =~ /\A\s*\Z/m || data =~ /;\s*\Z/m
        data
      else
        # Otherwise, append a semicolon and newline
        "#{data};\n"
      end
    end
  end
end

Version data entries

157 entries across 132 versions & 22 rubygems

Version Path
sprockets-2.12.5 lib/sprockets/safety_colons.rb
arcabouco-0.2.13 vendor/bundle/gems/sprockets-2.12.4/lib/sprockets/safety_colons.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/sprockets-2.12.4/lib/sprockets/safety_colons.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/sprockets-2.12.3/lib/sprockets/safety_colons.rb
sprockets-2.12.4 lib/sprockets/safety_colons.rb
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/safety_colons.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/safety_colons.rb
sprockets-2.12.3 lib/sprockets/safety_colons.rb
sprockets-2.11.3 lib/sprockets/safety_colons.rb
sprockets-2.10.2 lib/sprockets/safety_colons.rb
sprockets-2.9.4 lib/sprockets/safety_colons.rb
sprockets-2.8.3 lib/sprockets/safety_colons.rb
sprockets-2.7.1 lib/sprockets/safety_colons.rb
sprockets-2.6.1 lib/sprockets/safety_colons.rb
sprockets-2.5.1 lib/sprockets/safety_colons.rb
sprockets-2.4.6 lib/sprockets/safety_colons.rb
sprockets-2.3.3 lib/sprockets/safety_colons.rb
sprockets-2.2.3 lib/sprockets/safety_colons.rb
sprockets-2.1.4 lib/sprockets/safety_colons.rb
sprockets-2.0.5 lib/sprockets/safety_colons.rb