diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-10-21 10:45:58 -0700 |
---|---|---|
committer | Guillermo Iguaran <guilleiguaran@gmail.com> | 2013-10-21 10:45:58 -0700 |
commit | 1bf87c1ee2e01be272ffe81b3908ea51f559ecb2 (patch) | |
tree | 1ba8416646fe4ee61d6a27656dd5ef0e5b336cca /guides | |
parent | 19639c7184bf40054dcedbbfe00eff164abf133f (diff) | |
parent | eb6defbae90510732038e546dd773bb5433fadec (diff) | |
download | rails-1bf87c1ee2e01be272ffe81b3908ea51f559ecb2.tar.gz rails-1bf87c1ee2e01be272ffe81b3908ea51f559ecb2.tar.bz2 rails-1bf87c1ee2e01be272ffe81b3908ea51f559ecb2.zip |
Merge pull request #12603 from dv/fix-tilt-template-in-asset-pipeline-docs
Update docs on Tilt::Template in Asset Pipeline guide
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/asset_pipeline.md | 11 |
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 |