aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorDavid Verhasselt <david@crowdway.com>2013-10-21 20:34:11 +0300
committerDavid Verhasselt <david@crowdway.com>2013-10-21 20:34:11 +0300
commiteb6defbae90510732038e546dd773bb5433fadec (patch)
tree1ba8416646fe4ee61d6a27656dd5ef0e5b336cca /guides
parent19639c7184bf40054dcedbbfe00eff164abf133f (diff)
downloadrails-eb6defbae90510732038e546dd773bb5433fadec.tar.gz
rails-eb6defbae90510732038e546dd773bb5433fadec.tar.bz2
rails-eb6defbae90510732038e546dd773bb5433fadec.zip
Update docs on Tilt::Template in Asset Pipeline guide
Diffstat (limited to 'guides')
-rw-r--r--guides/source/asset_pipeline.md11
1 files changed, 8 insertions, 3 deletions
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md
index 7cb42f18d9..40a6f3ebc7 100644
--- a/guides/source/asset_pipeline.md
+++ b/guides/source/asset_pipeline.md
@@ -1044,17 +1044,22 @@ 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 `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
[`Tilt::Template`](https://github.com/rtomayko/tilt/blob/master/lib/tilt/template.rb)
sources to learn more.
```ruby
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}!"
end
end
end