Browse files

Merge pull request #12603 from dv/fix-tilt-template-in-asset-pipeline…


Update docs on Tilt::Template in Asset Pipeline guide
  • Loading branch information...
2 parents 19639c7 + eb6defb commit 1bf87c1ee2e01be272ffe81b3908ea51f559ecb2 @guilleiguaran guilleiguaran committed Oct 21, 2013
Showing with 8 additions and 3 deletions.
  1. +8 −3 guides/source/
@@ -1044,17 +1044,22 @@ Making Your Library or Gem a Pre-Processor
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
+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
sources to learn more.
module BangBang
class Template < ::Tilt::Template
+ def prepare
+ # Do any initialization here
+ end
# Adds a "!" to original template.
def evaluate(scope, locals, &block)
- "#{@code}!"
+ "#{data}!"

0 comments on commit 1bf87c1

Please sign in to comment.