Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create Sprockets::Template

  • Loading branch information...
commit ec04deb26be303cb7705d69527f7180cd8343eb7 1 parent 05d382d
@josh josh authored
View
4 lib/sprockets.rb
@@ -14,6 +14,7 @@ module Sprockets
autoload :StaticAsset, "sprockets/static_asset"
# Processing
+ autoload :Template, "sprockets/template"
autoload :Context, "sprockets/context"
autoload :CoffeeScriptTemplate, "sprockets/coffee_script_template"
autoload :EcoTemplate, "sprockets/eco_template"
@@ -90,9 +91,6 @@ module Cache
require 'sprockets/yui_compressor'
register_compressor 'application/javascript', :yui, YUICompressor
- # Cherry pick the default Tilt engines that make sense for
- # Sprockets. We don't need ones that only generate html like HAML.
-
# Mmm, CoffeeScript
register_engine '.coffee', CoffeeScriptTemplate
View
4 lib/sprockets/charset_normalizer.rb
@@ -1,5 +1,3 @@
-require 'tilt'
-
module Sprockets
# Some browsers have issues with stylesheets that contain multiple
# `@charset` definitions. The issue surfaces while using Sass since
@@ -18,7 +16,7 @@ module Sprockets
#
# environment.unregister_bundle_processor 'text/css', Sprockets::CharsetNormalizer
#
- class CharsetNormalizer < Tilt::Template
+ class CharsetNormalizer < Template
def prepare
end
View
4 lib/sprockets/closure_compressor.rb
@@ -1,7 +1,5 @@
-require 'tilt'
-
module Sprockets
- class ClosureCompressor < Tilt::Template
+ class ClosureCompressor < Template
self.default_mime_type = 'application/javascript'
def self.engine_initialized?
View
4 lib/sprockets/coffee_script_template.rb
@@ -1,7 +1,5 @@
-require 'tilt'
-
module Sprockets
- class CoffeeScriptTemplate < Tilt::Template
+ class CoffeeScriptTemplate < Template
self.default_mime_type = 'application/javascript'
def self.engine_initialized?
View
2  lib/sprockets/context.rb
@@ -6,7 +6,7 @@
require 'set'
module Sprockets
- # `Context` provides helper methods to all `Tilt` processors. They
+ # `Context` provides helper methods to all `Template` processors. They
# are typically accessed by ERB templates. You can mix in custom
# helpers by injecting them into `Environment#context_class`. Do not
# mix them into `Context` directly.
View
12 lib/sprockets/directive_processor.rb
@@ -1,6 +1,5 @@
require 'pathname'
require 'shellwords'
-require 'tilt'
require 'yaml'
module Sprockets
@@ -20,10 +19,9 @@ module Sprockets
# *= require "baz"
# */
#
- # The Processor is implemented as a `Tilt::Template` and is loosely
- # coupled to Sprockets. This makes it possible to disable or modify
- # the processor to do whatever you'd like. You could add your own
- # custom directives or invent your own directive syntax.
+ # This makes it possible to disable or modify the processor to do whatever
+ # you'd like. You could add your own custom directives or invent your own
+ # directive syntax.
#
# `Environment#processors` includes `DirectiveProcessor` by default.
#
@@ -36,7 +34,7 @@ module Sprockets
#
# env.register_processor('text/css', MyProcessor)
#
- class DirectiveProcessor < Tilt::Template
+ class DirectiveProcessor < Template
# Directives will only be picked up if they are in the header
# of the source file. C style (/* */), JavaScript (//), and
# Ruby (#) comments are supported.
@@ -82,7 +80,7 @@ def prepare
@included_pathnames = []
end
- # Implemented for Tilt#render.
+ # Implemented for Template#render.
#
# `context` is a `Context` instance with methods that allow you to
# access the environment and append to the bundle. See `Context`
View
8 lib/sprockets/eco_template.rb
@@ -1,20 +1,18 @@
-require 'tilt'
-
module Sprockets
- # Tilt engine class for the Eco compiler. Depends on the `eco` gem.
+ # Template engine class for the Eco compiler. Depends on the `eco` gem.
#
# For more infomation see:
#
# https://github.com/sstephenson/ruby-eco
# https://github.com/sstephenson/eco
#
- class EcoTemplate < Tilt::Template
+ class EcoTemplate < Template
# Check to see if Eco is loaded
def self.engine_initialized?
defined? ::Eco
end
- # Autoload eco library. If the library isn't loaded, Tilt will produce
+ # Autoload eco library. If the library isn't loaded, it will produce
# a thread safetly warning. If you intend to use `.eco` files, you
# should explicitly require it.
def initialize_engine
View
8 lib/sprockets/ejs_template.rb
@@ -1,19 +1,17 @@
-require 'tilt'
-
module Sprockets
- # Tilt engine class for the EJS compiler. Depends on the `ejs` gem.
+ # Template engine class for the EJS compiler. Depends on the `ejs` gem.
#
# For more infomation see:
#
# https://github.com/sstephenson/ruby-ejs
#
- class EjsTemplate < Tilt::Template
+ class EjsTemplate < Template
# Check to see if EJS is loaded
def self.engine_initialized?
defined? ::EJS
end
- # Autoload ejs library. If the library isn't loaded, Tilt will produce
+ # Autoload ejs library. If the library isn't loaded, it will produce
# a thread safetly warning. If you intend to use `.ejs` files, you
# should explicitly require it.
def initialize_engine
View
4 lib/sprockets/engines.rb
@@ -15,8 +15,8 @@ module Sprockets
# left. `application.js.coffee.erb` will first run `ERBTemplate`
# then `CoffeeScriptTemplate`.
#
- # All `Engine`s must follow the `Tilt::Template` interface. It is
- # recommended to subclass `Tilt::Template`.
+ # All `Engine`s must follow the `Template` interface. It is
+ # recommended to subclass `Template`.
#
# Its recommended that you register engine changes on your local
# `Environment` instance.
View
1  lib/sprockets/environment.rb
@@ -5,7 +5,6 @@
require 'hike'
require 'logger'
require 'pathname'
-require 'tilt'
module Sprockets
class Environment < Base
View
4 lib/sprockets/erb_template.rb
@@ -1,7 +1,5 @@
-require 'tilt'
-
module Sprockets
- class ERBTemplate < Tilt::Template
+ class ERBTemplate < Template
def self.engine_initialized?
defined? ::ERB
end
View
4 lib/sprockets/jst_processor.rb
@@ -1,7 +1,5 @@
-require 'tilt'
-
module Sprockets
- class JstProcessor < Tilt::Template
+ class JstProcessor < Template
self.default_mime_type = 'application/javascript'
def self.default_namespace
View
4 lib/sprockets/less_template.rb
@@ -1,7 +1,5 @@
-require 'tilt'
-
module Sprockets
- class LessTemplate < Tilt::Template
+ class LessTemplate < Template
self.default_mime_type = 'text/css'
def self.engine_initialized?
View
12 lib/sprockets/processing.rb
@@ -28,8 +28,8 @@ def processors(*args)
# Preprocessors are ran before Postprocessors and Engine
# processors.
#
- # All `Processor`s must follow the `Tilt::Template` interface. It is
- # recommended to subclass `Tilt::Template`.
+ # All `Processor`s must follow the `Template` interface. It is
+ # recommended to subclass `Template`.
def preprocessors(mime_type = nil)
if mime_type
@preprocessors[mime_type].dup
@@ -44,8 +44,8 @@ def preprocessors(mime_type = nil)
#
# Postprocessors are ran after Preprocessors and Engine processors.
#
- # All `Processor`s must follow the `Tilt::Template` interface. It is
- # recommended to subclass `Tilt::Template`.
+ # All `Processor`s must follow the `Template` interface. It is
+ # recommended to subclass `Template`.
def postprocessors(mime_type = nil)
if mime_type
@postprocessors[mime_type].dup
@@ -127,8 +127,8 @@ def unregister_postprocessor(mime_type, klass)
# Bundle Processors are ran on concatenated assets rather than
# individual files.
#
- # All `Processor`s must follow the `Tilt::Template` interface. It is
- # recommended to subclass `Tilt::Template`.
+ # All `Processor`s must follow the `Template` interface. It is
+ # recommended to subclass `Template`.
def bundle_processors(mime_type = nil)
if mime_type
@bundle_processors[mime_type].dup
View
4 lib/sprockets/processor.rb
@@ -1,5 +1,3 @@
-require 'tilt'
-
module Sprockets
# `Processor` creates an anonymous processor class from a block.
#
@@ -7,7 +5,7 @@ module Sprockets
# # ...
# end
#
- class Processor < Tilt::Template
+ class Processor < Template
def self.make_processor(klass, &block) # :nodoc:
return klass unless block_given?
View
4 lib/sprockets/safety_colons.rb
@@ -1,5 +1,3 @@
-require 'tilt'
-
module Sprockets
# For JS developers who are colonfobic, concatenating JS files using
# the module pattern usually leads to syntax errors.
@@ -11,7 +9,7 @@ module Sprockets
#
# environment.unregister_postprocessor 'application/javascript', Sprockets::SafetyColons
#
- class SafetyColons < Tilt::Template
+ class SafetyColons < Template
def prepare
end
View
4 lib/sprockets/sass_compressor.rb
@@ -1,7 +1,5 @@
-require 'tilt'
-
module Sprockets
- class SassCompressor < Tilt::Template
+ class SassCompressor < Template
self.default_mime_type = 'text/css'
def self.engine_initialized?
View
10 lib/sprockets/sass_template.rb
@@ -1,12 +1,6 @@
-require 'tilt'
-
module Sprockets
- # This custom Tilt handler replaces the one built into Tilt. The
- # main difference is that it uses a custom importer that plays nice
- # with sprocket's caching system.
- #
- # See `SassImporter` for more infomation.
- class SassTemplate < Tilt::Template
+ # Also see `SassImporter` for more infomation.
+ class SassTemplate < Template
self.default_mime_type = 'text/css'
def self.engine_initialized?
View
2  lib/sprockets/scss_template.rb
@@ -1,8 +1,6 @@
require 'sprockets/sass_template'
module Sprockets
- # Scss handler to replace Tilt's builtin one. See `SassTemplate` and
- # `SassImporter` for more infomation.
class ScssTemplate < SassTemplate
self.default_mime_type = 'text/css'
View
4 lib/sprockets/string_template.rb
@@ -1,7 +1,5 @@
-require 'tilt'
-
module Sprockets
- class StringTemplate < Tilt::Template
+ class StringTemplate < Template
def prepare
hash = "TILT#{data.hash.abs}"
@code = "<<#{hash}.chomp\n#{data}\n#{hash}"
View
6 lib/sprockets/template.rb
@@ -0,0 +1,6 @@
+require 'tilt'
+
+module Sprockets
+ class Template < ::Tilt::Template
+ end
+end
View
4 lib/sprockets/uglifier_compressor.rb
@@ -1,7 +1,5 @@
-require 'tilt'
-
module Sprockets
- class UglifierCompressor < Tilt::Template
+ class UglifierCompressor < Template
self.default_mime_type = 'application/javascript'
def self.engine_initialized?
View
4 lib/sprockets/yui_compressor.rb
@@ -1,7 +1,5 @@
-require 'tilt'
-
module Sprockets
- class YUICompressor < Tilt::Template
+ class YUICompressor < Template
def self.engine_initialized?
defined?(::YUI)
end
Please sign in to comment.
Something went wrong with that request. Please try again.