Permalink
Browse files

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

…-docs

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/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

0 comments on commit 1bf87c1

Please sign in to comment.