aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorTom Prats <tprats108@gmail.com>2016-11-17 17:42:11 -0500
committerTom Prats <tprats108@gmail.com>2016-11-17 18:18:14 -0500
commitdd66493d70da4b9b2edc22d7273cb407f3cf3194 (patch)
tree376a971c36b721d5c3c97972b4071ddd7fbfeef6 /guides
parent7a3be90dce82031952e9abe07d9de7aedf1cb521 (diff)
downloadrails-dd66493d70da4b9b2edc22d7273cb407f3cf3194.tar.gz
rails-dd66493d70da4b9b2edc22d7273cb407f3cf3194.tar.bz2
rails-dd66493d70da4b9b2edc22d7273cb407f3cf3194.zip
Updated Sprockets Documentation
Diffstat (limited to 'guides')
-rw-r--r--guides/source/asset_pipeline.md32
1 files changed, 11 insertions, 21 deletions
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md
index 41dfeea84d..25717e04e4 100644
--- a/guides/source/asset_pipeline.md
+++ b/guides/source/asset_pipeline.md
@@ -1227,35 +1227,25 @@ Sprockets.
Making Your Library or Gem a Pre-Processor
------------------------------------------
-As Sprockets uses [Tilt](https://github.com/rtomayko/tilt) as a generic
-interface to different templating engines, your gem should just implement the
-Tilt template protocol. Normally, you would subclass `Tilt::Template` and
-reimplement the `prepare` method, which initializes your template, and the
-`evaluate` method, which returns the processed source. The original source is
-stored in `data`. Have a look at
-[`Tilt::Template`](https://github.com/rtomayko/tilt/blob/master/lib/tilt/template.rb)
-sources to learn more.
+Sprockets uses Processors, Transformers, Compressors, and Exporters to extend
+Sprockets functionality. Have a look at
+[Extending Sprockets](https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md)
+to learn more. Here we registered a preprocessor to add a comment to the end
+of text/css (.css) files.
```ruby
-module BangBang
- class Template < ::Tilt::Template
- def prepare
- # Do any initialization here
- end
-
- # Adds a "!" to original template.
- def evaluate(scope, locals, &block)
- "#{data}!"
- end
+module AddComment
+ def self.call(input)
+ { data: input[:data] + "/* Hello From my sprockets extension */" }
end
end
```
-Now that you have a `Template` class, it's time to associate it with an
-extension for template files:
+Now that you have a module that modifies the input data, it's time to register
+it as a preprocessor for your mime type.
```ruby
-Sprockets.register_engine '.bang', BangBang::Template
+Sprockets.register_preprocessor 'text/css', AddComment
```
Upgrading from Old Versions of Rails