Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Merge pull request #8869 from goshakkk/guides-asset-pipeline-tilt

Add asset pipeline guides section on implementing & registering own engines
  • Loading branch information...
2 parents 5be6fa5 + 38efe87 commit 34126fa6e38b0010856d3ec8af04bdcfd9dde662 @guilleiguaran guilleiguaran committed
Showing with 25 additions and 1 deletion.
  1. +25 −1 guides/source/
26 guides/source/
@@ -720,7 +720,31 @@ A good example of this is the `jquery-rails` gem which comes with Rails as the s
Making Your Library or Gem a Pre-Processor
-TODO: Registering gems on [Tilt]( enabling Sprockets to find them.
+As Sprockets uses [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 `evaluate` method to return final
+output. Template source is stored at `@code`. Have a look at
+sources to learn more.
+module BangBang
+ class Template < ::Tilt::Template
+ # Adds a "!" to original template.
+ def evaluate(scope, locals, &block)
+ "#{@code}!"
+ end
+ end
+Now that you have a `Template` class, it's time to associate it with an
+extenstion for template files:
+Sprockets.register_engine '.bang', BangBang::Template
Upgrading from Old Versions of Rails

0 comments on commit 34126fa

Please sign in to comment.
Something went wrong with that request. Please try again.