tilt 2.0.9 → 2.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tilt.rb +1 -1
  3. data/lib/tilt/template.rb +7 -12
  4. metadata +3 -104
  5. data/CHANGELOG.md +0 -132
  6. data/Gemfile +0 -70
  7. data/HACKING +0 -16
  8. data/README.md +0 -233
  9. data/Rakefile +0 -106
  10. data/docs/TEMPLATES.md +0 -555
  11. data/docs/common.css +0 -14
  12. data/man/index.txt +0 -2
  13. data/man/tilt.1.ronn +0 -59
  14. data/test/markaby/locals.mab +0 -1
  15. data/test/markaby/markaby.mab +0 -1
  16. data/test/markaby/markaby_other_static.mab +0 -1
  17. data/test/markaby/render_twice.mab +0 -1
  18. data/test/markaby/scope.mab +0 -1
  19. data/test/markaby/yielding.mab +0 -2
  20. data/test/mytemplate.rb +0 -2
  21. data/test/test_helper.rb +0 -64
  22. data/test/tilt_asciidoctor_test.rb +0 -50
  23. data/test/tilt_babeltemplate.rb +0 -33
  24. data/test/tilt_blueclothtemplate_test.rb +0 -33
  25. data/test/tilt_buildertemplate_test.rb +0 -72
  26. data/test/tilt_cache_test.rb +0 -43
  27. data/test/tilt_coffeescripttemplate_test.rb +0 -141
  28. data/test/tilt_commonmarkertemplate_test.rb +0 -28
  29. data/test/tilt_compilesite_test.rb +0 -51
  30. data/test/tilt_creoletemplate_test.rb +0 -24
  31. data/test/tilt_csv_test.rb +0 -77
  32. data/test/tilt_erbtemplate_test.rb +0 -239
  33. data/test/tilt_erubistemplate_test.rb +0 -151
  34. data/test/tilt_erubitemplate_test.rb +0 -158
  35. data/test/tilt_etannitemplate_test.rb +0 -174
  36. data/test/tilt_hamltemplate_test.rb +0 -166
  37. data/test/tilt_kramdown_test.rb +0 -20
  38. data/test/tilt_lesstemplate_test.less +0 -1
  39. data/test/tilt_lesstemplate_test.rb +0 -42
  40. data/test/tilt_liquidtemplate_test.rb +0 -87
  41. data/test/tilt_livescripttemplate_test.rb +0 -37
  42. data/test/tilt_mapping_test.rb +0 -232
  43. data/test/tilt_markaby_test.rb +0 -88
  44. data/test/tilt_markdown_test.rb +0 -186
  45. data/test/tilt_marukutemplate_test.rb +0 -36
  46. data/test/tilt_metadata_test.rb +0 -42
  47. data/test/tilt_nokogiritemplate_test.rb +0 -87
  48. data/test/tilt_pandoctemplate_test.rb +0 -67
  49. data/test/tilt_prawntemplate.prawn +0 -1
  50. data/test/tilt_prawntemplate_test.rb +0 -75
  51. data/test/tilt_radiustemplate_test.rb +0 -75
  52. data/test/tilt_rdiscounttemplate_test.rb +0 -43
  53. data/test/tilt_rdoctemplate_test.rb +0 -29
  54. data/test/tilt_redcarpettemplate_test.rb +0 -54
  55. data/test/tilt_redclothtemplate_test.rb +0 -36
  56. data/test/tilt_rstpandoctemplate_test.rb +0 -32
  57. data/test/tilt_sasstemplate_test.rb +0 -42
  58. data/test/tilt_sigil_test.rb +0 -41
  59. data/test/tilt_stringtemplate_test.rb +0 -171
  60. data/test/tilt_template_test.rb +0 -314
  61. data/test/tilt_test.rb +0 -60
  62. data/test/tilt_typescript_test.rb +0 -38
  63. data/test/tilt_wikiclothtemplate_test.rb +0 -32
  64. data/test/tilt_yajltemplate_test.rb +0 -101
  65. data/tilt.gemspec +0 -130
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 628b7587af284142a071a75dec94e684b6972d16
4
- data.tar.gz: a686e34c2f8d764a74e2760fe5af2fc22c27b66d
3
+ metadata.gz: 65edfb577c11890055c06be1af7c6cd1692d6bb1
4
+ data.tar.gz: 025cb576450017fe953040a197522416e98c7835
5
5
  SHA512:
6
- metadata.gz: b802450ebc32e4d50d65af2bf827bf8e6b92d85787ea9507701d70e6c0e8df911fce4402e53e99e95029d11daa4bcbca6ed99f5c90fa0235d0051d7a290a6446
7
- data.tar.gz: a2db67256a1c846deabd6520d943e101645ea25cb610d022e60f2755dbddddfd8197275c6783ed663f569538647553714a1151d6d660887caf8ae6662b008159
6
+ metadata.gz: f1bbd4f61540f418aed012bd34cca939a7a208f0dc73ec5283041a0611fb629d5941bf24ab2976e2038774599b5d5e8f29c7beb0fababdf91c6f2d4eb9628a0b
7
+ data.tar.gz: 32cb517066dc3550f33b201980884479dbd387864133267ac1563fcfa8500386bbcf204ca0fbb9c98bac8f910cc1af647ff9464839806b1d32a088865c0d6e52
@@ -4,7 +4,7 @@ require 'tilt/template'
4
4
  # Namespace for Tilt. This module is not intended to be included anywhere.
5
5
  module Tilt
6
6
  # Current version.
7
- VERSION = '2.0.9'
7
+ VERSION = '2.0.10'
8
8
 
9
9
  @default_mapping = Mapping.new
10
10
 
@@ -166,7 +166,7 @@ module Tilt
166
166
  def evaluate(scope, locals, &block)
167
167
  locals_keys = locals.keys
168
168
  locals_keys.sort!{|x, y| x.to_s <=> y.to_s}
169
- method = compiled_method(locals_keys)
169
+ method = compiled_method(locals_keys, scope.is_a?(Module) ? scope : scope.class)
170
170
  method.bind(scope).call(locals, &block)
171
171
  end
172
172
 
@@ -231,9 +231,9 @@ module Tilt
231
231
  end
232
232
 
233
233
  # The compiled method for the locals keys provided.
234
- def compiled_method(locals_keys)
234
+ def compiled_method(locals_keys, scope_class=nil)
235
235
  LOCK.synchronize do
236
- @compiled_method[locals_keys] ||= compile_template_method(locals_keys)
236
+ @compiled_method[[scope_class, locals_keys]] ||= compile_template_method(locals_keys, scope_class)
237
237
  end
238
238
  end
239
239
 
@@ -247,7 +247,7 @@ module Tilt
247
247
  end.join("\n")
248
248
  end
249
249
 
250
- def compile_template_method(local_keys)
250
+ def compile_template_method(local_keys, scope_class=nil)
251
251
  source, offset = precompiled(local_keys)
252
252
  local_code = local_extraction(local_keys)
253
253
 
@@ -261,17 +261,12 @@ module Tilt
261
261
  method_source << <<-RUBY
262
262
  TOPOBJECT.class_eval do
263
263
  def #{method_name}(locals)
264
- Thread.current[:tilt_vars] = [self, locals]
265
- class << self
266
- this, locals = Thread.current[:tilt_vars]
267
- locals = locals
268
- this.instance_eval do
269
- #{local_code}
264
+ #{local_code}
270
265
  RUBY
271
266
  offset += method_source.count("\n")
272
267
  method_source << source
273
- method_source << "\nend;end;end;end"
274
- Object.class_eval(method_source, eval_file, line - offset)
268
+ method_source << "\nend;end;"
269
+ (scope_class || Object).class_eval(method_source, eval_file, line - offset)
275
270
  unbind_compiled_method(method_name)
276
271
  end
277
272
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.9
4
+ version: 2.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-28 00:00:00.000000000 Z
11
+ date: 2019-09-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generic interface to multiple Ruby template engines
14
14
  email: r@tomayko.com
@@ -17,15 +17,8 @@ executables:
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - CHANGELOG.md
21
20
  - COPYING
22
- - Gemfile
23
- - HACKING
24
- - README.md
25
- - Rakefile
26
21
  - bin/tilt
27
- - docs/TEMPLATES.md
28
- - docs/common.css
29
22
  - lib/tilt.rb
30
23
  - lib/tilt/asciidoc.rb
31
24
  - lib/tilt/babel.rb
@@ -65,60 +58,6 @@ files:
65
58
  - lib/tilt/typescript.rb
66
59
  - lib/tilt/wikicloth.rb
67
60
  - lib/tilt/yajl.rb
68
- - man/index.txt
69
- - man/tilt.1.ronn
70
- - test/markaby/locals.mab
71
- - test/markaby/markaby.mab
72
- - test/markaby/markaby_other_static.mab
73
- - test/markaby/render_twice.mab
74
- - test/markaby/scope.mab
75
- - test/markaby/yielding.mab
76
- - test/mytemplate.rb
77
- - test/test_helper.rb
78
- - test/tilt_asciidoctor_test.rb
79
- - test/tilt_babeltemplate.rb
80
- - test/tilt_blueclothtemplate_test.rb
81
- - test/tilt_buildertemplate_test.rb
82
- - test/tilt_cache_test.rb
83
- - test/tilt_coffeescripttemplate_test.rb
84
- - test/tilt_commonmarkertemplate_test.rb
85
- - test/tilt_compilesite_test.rb
86
- - test/tilt_creoletemplate_test.rb
87
- - test/tilt_csv_test.rb
88
- - test/tilt_erbtemplate_test.rb
89
- - test/tilt_erubistemplate_test.rb
90
- - test/tilt_erubitemplate_test.rb
91
- - test/tilt_etannitemplate_test.rb
92
- - test/tilt_hamltemplate_test.rb
93
- - test/tilt_kramdown_test.rb
94
- - test/tilt_lesstemplate_test.less
95
- - test/tilt_lesstemplate_test.rb
96
- - test/tilt_liquidtemplate_test.rb
97
- - test/tilt_livescripttemplate_test.rb
98
- - test/tilt_mapping_test.rb
99
- - test/tilt_markaby_test.rb
100
- - test/tilt_markdown_test.rb
101
- - test/tilt_marukutemplate_test.rb
102
- - test/tilt_metadata_test.rb
103
- - test/tilt_nokogiritemplate_test.rb
104
- - test/tilt_pandoctemplate_test.rb
105
- - test/tilt_prawntemplate.prawn
106
- - test/tilt_prawntemplate_test.rb
107
- - test/tilt_radiustemplate_test.rb
108
- - test/tilt_rdiscounttemplate_test.rb
109
- - test/tilt_rdoctemplate_test.rb
110
- - test/tilt_redcarpettemplate_test.rb
111
- - test/tilt_redclothtemplate_test.rb
112
- - test/tilt_rstpandoctemplate_test.rb
113
- - test/tilt_sasstemplate_test.rb
114
- - test/tilt_sigil_test.rb
115
- - test/tilt_stringtemplate_test.rb
116
- - test/tilt_template_test.rb
117
- - test/tilt_test.rb
118
- - test/tilt_typescript_test.rb
119
- - test/tilt_wikiclothtemplate_test.rb
120
- - test/tilt_yajltemplate_test.rb
121
- - tilt.gemspec
122
61
  homepage: http://github.com/rtomayko/tilt/
123
62
  licenses:
124
63
  - MIT
@@ -149,44 +88,4 @@ rubygems_version: 2.6.11
149
88
  signing_key:
150
89
  specification_version: 2
151
90
  summary: Generic interface to multiple Ruby template engines
152
- test_files:
153
- - test/tilt_asciidoctor_test.rb
154
- - test/tilt_blueclothtemplate_test.rb
155
- - test/tilt_buildertemplate_test.rb
156
- - test/tilt_cache_test.rb
157
- - test/tilt_coffeescripttemplate_test.rb
158
- - test/tilt_commonmarkertemplate_test.rb
159
- - test/tilt_compilesite_test.rb
160
- - test/tilt_creoletemplate_test.rb
161
- - test/tilt_csv_test.rb
162
- - test/tilt_erbtemplate_test.rb
163
- - test/tilt_erubistemplate_test.rb
164
- - test/tilt_erubitemplate_test.rb
165
- - test/tilt_etannitemplate_test.rb
166
- - test/tilt_hamltemplate_test.rb
167
- - test/tilt_kramdown_test.rb
168
- - test/tilt_lesstemplate_test.rb
169
- - test/tilt_liquidtemplate_test.rb
170
- - test/tilt_livescripttemplate_test.rb
171
- - test/tilt_mapping_test.rb
172
- - test/tilt_markaby_test.rb
173
- - test/tilt_markdown_test.rb
174
- - test/tilt_marukutemplate_test.rb
175
- - test/tilt_metadata_test.rb
176
- - test/tilt_nokogiritemplate_test.rb
177
- - test/tilt_pandoctemplate_test.rb
178
- - test/tilt_prawntemplate_test.rb
179
- - test/tilt_radiustemplate_test.rb
180
- - test/tilt_rdiscounttemplate_test.rb
181
- - test/tilt_rdoctemplate_test.rb
182
- - test/tilt_redcarpettemplate_test.rb
183
- - test/tilt_redclothtemplate_test.rb
184
- - test/tilt_rstpandoctemplate_test.rb
185
- - test/tilt_sasstemplate_test.rb
186
- - test/tilt_sigil_test.rb
187
- - test/tilt_stringtemplate_test.rb
188
- - test/tilt_template_test.rb
189
- - test/tilt_test.rb
190
- - test/tilt_typescript_test.rb
191
- - test/tilt_wikiclothtemplate_test.rb
192
- - test/tilt_yajltemplate_test.rb
91
+ test_files: []
@@ -1,132 +0,0 @@
1
- ## master
2
-
3
- ## 2.0.9 (2018-11-28)
4
-
5
- * Use new ERB API in Ruby 2.6 (#329, koic)
6
- * Support the new sassc gem (#336, jdickey, judofyr)
7
-
8
- ## 2.0.8 (2017-07-24)
9
-
10
- * Register .tsx for TypeScript (#315, backus)
11
- * Use Haml 5's new API (#312, k0kubun)
12
- * Use correct parser options for CommonMarker (#320, rewritten)
13
- * Suppress warnings when no locals are used (#304, amatsuda)
14
- * Haml: Accept `outvar` (#317, k0kubun)
15
-
16
- ## 2.0.7 (2017-03-19)
17
-
18
- * Do not modify BasicObject during template compilation on ruby 2.0+ (#309, jeremyevans)
19
-
20
- ## 2.0.6 (2017-01-26)
21
-
22
- * Add support for LiveScript (#286, @Announcement Jacob Francis Powers)
23
- * Add support for Sigil (#302, winebarrel)
24
- * Add support for Erubi (#308, jeremyevans)
25
- * Add support for options in Liquid (#298, #299, laCour)
26
- * Always sort locals by strings (#307, jeremyevans)
27
-
28
- * Fix test warnings (#305, amatsuda)
29
- * Fix indentation (#293, yui-knk)
30
- * Use SVG badges in README (#294, vasinov)
31
- * Fix typo and trailing space (#295, #296, karloescota)
32
-
33
- ## 2.0.5 (2016-06-02)
34
-
35
- * Add support for reST using Pandoc (#284, mfenner)
36
- * Make lazy loading thread-safe; remove warning (judofyr)
37
-
38
- ## 2.0.4 (2016-05-16)
39
-
40
- * Fix regression in BuilderTemplate (#283, judofyr)
41
-
42
- ## 2.0.3 (2016-05-12)
43
-
44
- * Add Pandoc support (#276, jmuheim)
45
- * Add CommonMark support (#282, raphink)
46
- * Add TypeScript support (#278, nghitran)
47
- * Work with frozen string literal (#274, jeremyevans)
48
- * Add MIME type for Babel (#273, SaitoWu)
49
-
50
- ## 2.0.2 (2016-01-06)
51
-
52
- * Pass options to Redcarpet (#250, hughbien)
53
- * Haml: Improve error message on frozen self (judofyr)
54
- * Add basic support for Babel (judofyr)
55
- * Add support for .litcoffee (#243, judofyr, mr-vinn)
56
- * Document Tilt::Cache (#266, tommay)
57
- * Sort local keys for better caching (#257, jeremyevans)
58
- * Add more CSV options (#256, Juanmcuello)
59
- * Add Prawn template (kematzy)
60
- * Improve cache-miss performance in Tilt::Cache (#251, tommay)
61
- * Add man page (#241, josephholsten)
62
- * Support YAML/JSON data in bin/tilt (#241, josephholsten)
63
-
64
- ## 2.0.1 (2014-03-21)
65
-
66
- * Fix Tilt::Mapping bug in Ruby 2.1.0 (9589652c569760298f2647f7a0f9ed4f85129f20)
67
- * Fix `tilt --list` (#223, Achrome)
68
- * Fix circular require (#221, amarshall)
69
-
70
- ## 2.0.0 (2013-11-30)
71
-
72
- * Support Pathname in Template#new (#219, kabturek)
73
- * Add Mapping#templates_for (judofyr)
74
- * Support old-style #register (judofyr)
75
- * Add Handlebars as external template engine (#204, judofyr, jimothyGator)
76
- * Add org-ruby as external template engine (#207, judofyr, minad)
77
- * Documentation typo (#208, elgalu)
78
-
79
- ## 2.0.0.beta1 (2013-07-16)
80
-
81
- * Documentation typo (#202, chip)
82
- * Use YARD for documentation (#189, judofyr)
83
- * Add Slim as an external template engine (judofyr)
84
- * Add Tilt.templates_for (#121, judofyr)
85
- * Add Tilt.current_template (#151, judofyr)
86
- * Avoid loading all files in tilt.rb (#160, #187, judofyr)
87
- * Implement lazily required templates classes (#178, #187, judofyr)
88
- * Move #allows_script and default_mime_type to metadata (#187, judofyr)
89
- * Introduce Tilt::Mapping (#187, judofyr)
90
- * Make template compilation thread-safe (#191, judofyr)
91
-
92
- ## 1.4.1 (2013-05-08)
93
-
94
- * Support Arrays in pre/postambles (#193, jbwiv)
95
-
96
- ## 1.4.0 (2013-05-01)
97
-
98
- * Better encoding support
99
-
100
- ## 1.3.7 (2013-04-09)
101
-
102
- * Erubis: Check for the correct constant (#183, mattwildig)
103
- * Don't fail when BasicObject is defined in 1.8 (#182, technobrat, judofyr)
104
-
105
- ## 1.3.6 (2013-03-17)
106
-
107
- * Accept Hash that implements #path as options (#180, lawso017)
108
- * Changed extension for CsvTemplate from '.csv' to '.rcsv' (#177, alexgb)
109
-
110
- ## 1.3.5 (2013-03-06)
111
-
112
- * Fixed extension for PlainTemplate (judofyr)
113
- * Improved local variables regexp (#174, razorinc)
114
- * Added CHANGELOG.md
115
-
116
- ## 1.3.4 (2013-02-28)
117
-
118
- * Support RDoc 4.0 (#168, judofyr)
119
- * Add mention of Org-Mode support (#165, aslakknutsen)
120
- * Add AsciiDoctorTemplate (#163, #164, aslakknutsen)
121
- * Add PlainTextTemplate (nathanaeljones)
122
- * Restrict locals to valid variable names (#158, thinkerbot)
123
- * ERB: Improve trim mode support (#156, ssimeonov)
124
- * Add CSVTemplate (#153, alexgb)
125
- * Remove special case for 1.9.1 (#147, guilleiguaran)
126
- * Add allows\_script? method to Template (#143, bhollis)
127
- * Default to using Redcarpet2 (#139, DAddYE)
128
- * Allow File/Tempfile as filenames (#134, jamesotron)
129
- * Add EtanniTemplate (#131, manveru)
130
- * Support RDoc 3.10 (#112, timfel)
131
- * Always compile templates; remove old source evaluator (rtomayko)
132
- * Less: Options are now being passed to the parser (#106, cowboyd)
data/Gemfile DELETED
@@ -1,70 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- gem 'rake'
6
- gem 'minitest', '~> 5.0'
7
-
8
- group :development do
9
- gem 'yard', '~> 0.9.0'
10
- gem 'ronn', '~> 0.7.3'
11
- end
12
-
13
- can_execjs = (RUBY_VERSION >= '1.9.3')
14
-
15
- group :primary do
16
- gem 'builder'
17
- gem 'haml', '>= 4' if RUBY_VERSION >= '2.0.0'
18
- gem 'erubis'
19
- gem 'markaby'
20
-
21
- if ENV['OLD_SASS']
22
- gem 'sass'
23
- else
24
- gem 'sassc'
25
- end
26
-
27
- if can_execjs
28
- gem 'less'
29
- gem 'coffee-script'
30
- gem 'livescript'
31
- gem 'babel-transpiler'
32
- gem 'typescript-node'
33
- end
34
- end
35
-
36
- platform :mri do
37
- gem 'duktape', '~> 1.3.0.6' if can_execjs
38
- end
39
-
40
- group :secondary do
41
- gem 'creole'
42
- gem 'kramdown'
43
- gem 'rdoc'
44
- gem 'radius'
45
- gem 'asciidoctor', '>= 0.1.0'
46
- gem 'liquid'
47
- gem 'maruku'
48
- gem 'pandoc-ruby'
49
-
50
- if RUBY_VERSION > '1.9.3'
51
- gem 'prawn', '>= 2.0.0'
52
- gem 'pdf-reader', '~> 1.3.3'
53
- end
54
-
55
- gem 'nokogiri' if RUBY_VERSION > '1.9.2'
56
-
57
- platform :ruby do
58
- gem 'wikicloth'
59
- gem 'yajl-ruby'
60
- gem 'redcarpet' if RUBY_VERSION > '1.8.7'
61
- gem 'rdiscount', '>= 2.1.6' if RUBY_VERSION != '1.9.2'
62
- gem 'RedCloth'
63
- gem 'commonmarker' if RUBY_VERSION > '1.9.3'
64
- end
65
-
66
- platform :mri do
67
- gem 'bluecloth'
68
- end
69
- end
70
-
data/HACKING DELETED
@@ -1,16 +0,0 @@
1
- Clone:
2
-
3
- git clone git://github.com/rtomayko/tilt.git
4
- cd tilt
5
-
6
- Install needed packages under ./vendor and run tests (requires bundler):
7
-
8
- rake
9
-
10
- Run tests under your current gem environment. Do not install anything:
11
-
12
- rake test
13
-
14
- Only install needed packages under ./vendor:
15
-
16
- rake setup
data/README.md DELETED
@@ -1,233 +0,0 @@
1
- Tilt [![Build Status](https://secure.travis-ci.org/rtomayko/tilt.svg)](http://travis-ci.org/rtomayko/tilt) [![Inline docs](http://inch-ci.org/github/rtomayko/tilt.svg)](http://inch-ci.org/github/rtomayko/tilt) [![Security](https://hakiri.io/github/rtomayko/tilt/master.svg)](https://hakiri.io/github/rtomayko/tilt/master)
2
- ====
3
-
4
- **NOTE** The following file documents the current release of Tilt (2.0). See
5
- https://github.com/rtomayko/tilt/tree/tilt-1 for documentation for Tilt 1.4.
6
-
7
- Tilt is a thin interface over a bunch of different Ruby template engines in
8
- an attempt to make their usage as generic as possible. This is useful for web
9
- frameworks, static site generators, and other systems that support multiple
10
- template engines but don't want to code for each of them individually.
11
-
12
- The following features are supported for all template engines (assuming the
13
- feature is relevant to the engine):
14
-
15
- * Custom template evaluation scopes / bindings
16
- * Ability to pass locals to template evaluation
17
- * Support for passing a block to template evaluation for "yield"
18
- * Backtraces with correct filenames and line numbers
19
- * Template file caching and reloading
20
- * Fast, method-based template source compilation
21
-
22
- The primary goal is to get all of the things listed above right for all
23
- template engines included in the distribution.
24
-
25
- Support for these template engines is included with the package:
26
-
27
- | Engine | File Extensions | Required Libraries | Maintainer |
28
- | ----------------------- | ---------------------- | ------------------------------------------ | ----------- |
29
- | Asciidoctor | .ad, .adoc, .asciidoc | asciidoctor (>= 0.1.0) | Community |
30
- | ERB | .erb, .rhtml | none (included ruby stdlib) | Tilt team |
31
- | InterpolatedString | .str | none (included ruby core) | Tilt team |
32
- | Erubi | .erb, .rhtml, .erubi | erubi | Community |
33
- | Erubis | .erb, .rhtml, .erubis | erubis | Tilt team |
34
- | Haml | .haml | haml | Tilt team |
35
- | Sass | .sass | haml (< 3.1) or sass (>= 3.1) | Tilt team |
36
- | Scss | .scss | haml (< 3.1) or sass (>= 3.1) | Tilt team |
37
- | Less CSS | .less | less | Tilt team |
38
- | Builder | .builder | builder | Tilt team |
39
- | Liquid | .liquid | liquid | Community |
40
- | RDiscount | .markdown, .mkd, .md | rdiscount | Community |
41
- | Redcarpet | .markdown, .mkd, .md | redcarpet | Community |
42
- | BlueCloth | .markdown, .mkd, .md | bluecloth | Community |
43
- | Kramdown | .markdown, .mkd, .md | kramdown | Community |
44
- | Pandoc | .markdown, .mkd, .md | pandoc | Community |
45
- | reStructuredText | .rst | pandoc | Community |
46
- | Maruku | .markdown, .mkd, .md | maruku | Community |
47
- | CommonMarker | .markdown, .mkd, .md | commonmarker | Community |
48
- | RedCloth | .textile | redcloth | Community |
49
- | RDoc | .rdoc | rdoc | Tilt team |
50
- | Radius | .radius | radius | Community |
51
- | Markaby | .mab | markaby | Tilt team |
52
- | Nokogiri | .nokogiri | nokogiri | Community |
53
- | CoffeeScript | .coffee | coffee-script (+ javascript) | Tilt team |
54
- | CoffeeScript (literate) | .litcoffee | coffee-script (>= 1.5.0) (+ javascript) | Tilt team |
55
- | LiveScript | .ls | livescript (+ javascript) | Tilt team |
56
- | TypeScript | .ts | typescript (+ javascript) | Tilt team |
57
- | Creole (Wiki markup) | .wiki, .creole | creole | Community |
58
- | WikiCloth (Wiki markup) | .wiki, .mediawiki, .mw | wikicloth | Community |
59
- | Yajl | .yajl | yajl-ruby | Community |
60
- | CSV | .rcsv | none (Ruby >= 1.9), fastercsv (Ruby < 1.9) | Tilt team |
61
- | Prawn | .prawn | prawn (>= 2.0.0) | Community |
62
- | Babel | .es6, .babel, .jsx | babel-transpiler | Tilt team |
63
- | Opal | .rb | opal | Community |
64
- | Sigil | .sigil | sigil | Community |
65
-
66
- Every supported template engine has a *maintainer*. Note that this is the
67
- maintainer of the Tilt integration, not the maintainer of the template engine
68
- itself. The maintainer is responsible for providing an adequate integration and
69
- keeping backwards compatibility across Tilt version. Some integrations are
70
- maintained by the *community*, which is handled in the following way:
71
-
72
- - The Tilt team will liberally accept pull requests against the template
73
- integration. It's up to the community as a whole to make sure the integration
74
- stays consistent and backwards compatible over time.
75
- - Test failures in community-maintained integrations will not be prioritized by
76
- the Tilt team and a new version of Tilt might be released even though these
77
- tests are failing.
78
- - Anyone can become a maintainer for a template engine integration they care
79
- about. Just open an issue and we'll figure it out.
80
-
81
- These template engines ship with their own Tilt integration:
82
-
83
- | Engine | File Extensions | Required Libraries |
84
- | ------------------- | ---------------- | ------------------- |
85
- | Slim | .slim | slim (>= 0.7) |
86
- | Embedded JavaScript | | sprockets |
87
- | Embedded CoffeeScript | | sprockets |
88
- | JST | | sprockets |
89
- | Org-mode | .org | org-ruby (>= 0.6.2) |
90
- | Handlebars | .hbs, handlebars | tilt-handlebars |
91
- | Jbuilder | .jbuilder | tilt-jbuilder |
92
-
93
- See [TEMPLATES.md][t] for detailed information on template engine
94
- options and supported features.
95
-
96
- [t]: http://github.com/rtomayko/tilt/blob/master/docs/TEMPLATES.md
97
- "Tilt Template Engine Documentation"
98
-
99
- Basic Usage
100
- -----------
101
-
102
- Instant gratification:
103
-
104
- require 'erb'
105
- require 'tilt'
106
- template = Tilt.new('templates/foo.erb')
107
- => #<Tilt::ERBTemplate @file="templates/foo.erb" ...>
108
- output = template.render
109
- => "Hello world!"
110
-
111
- It's recommended that calling programs explicitly require template engine
112
- libraries (like 'erb' above) at load time. Tilt attempts to lazy require the
113
- template engine library the first time a template is created but this is
114
- prone to error in threaded environments.
115
-
116
- The {Tilt} module contains generic implementation classes for all supported
117
- template engines. Each template class adheres to the same interface for
118
- creation and rendering. In the instant gratification example, we let Tilt
119
- determine the template implementation class based on the filename, but
120
- {Tilt::Template} implementations can also be used directly:
121
-
122
- require 'tilt/haml'
123
- template = Tilt::HamlTemplate.new('templates/foo.haml')
124
- output = template.render
125
-
126
- The `render` method takes an optional evaluation scope and locals hash
127
- arguments. Here, the template is evaluated within the context of the
128
- `Person` object with locals `x` and `y`:
129
-
130
- require 'tilt/erb'
131
- template = Tilt::ERBTemplate.new('templates/foo.erb')
132
- joe = Person.find('joe')
133
- output = template.render(joe, :x => 35, :y => 42)
134
-
135
- If no scope is provided, the template is evaluated within the context of an
136
- object created with `Object.new`.
137
-
138
- A single `Template` instance's `render` method may be called multiple times
139
- with different scope and locals arguments. Continuing the previous example,
140
- we render the same compiled template but this time in jane's scope:
141
-
142
- jane = Person.find('jane')
143
- output = template.render(jane, :x => 22, :y => nil)
144
-
145
- Blocks can be passed to `render` for templates that support running
146
- arbitrary ruby code (usually with some form of `yield`). For instance,
147
- assuming the following in `foo.erb`:
148
-
149
- Hey <%= yield %>!
150
-
151
- The block passed to `render` is called on `yield`:
152
-
153
- template = Tilt::ERBTemplate.new('foo.erb')
154
- template.render { 'Joe' }
155
- # => "Hey Joe!"
156
-
157
- Template Mappings
158
- -----------------
159
-
160
- The {Tilt::Mapping} class includes methods for associating template
161
- implementation classes with filename patterns and for locating/instantiating
162
- template classes based on those associations.
163
-
164
- The {Tilt} module has a global instance of `Mapping` that is populated with the
165
- table of template engines above.
166
-
167
- The {Tilt.register} method associates a filename pattern with a specific
168
- template implementation. To use ERB for files ending in a `.bar` extension:
169
-
170
- >> Tilt.register Tilt::ERBTemplate, 'bar'
171
- >> Tilt.new('views/foo.bar')
172
- => #<Tilt::ERBTemplate @file="views/foo.bar" ...>
173
-
174
- Retrieving the template class for a file or file extension:
175
-
176
- >> Tilt['foo.bar']
177
- => Tilt::ERBTemplate
178
- >> Tilt['haml']
179
- => Tilt::HamlTemplate
180
-
181
- Retrieving a list of template classes for a file:
182
-
183
- >> Tilt.templates_for('foo.bar')
184
- => [Tilt::ERBTemplate]
185
- >> Tilt.templates_for('foo.haml.bar')
186
- => [Tilt::ERBTemplate, Tilt::HamlTemplate]
187
-
188
- The template class is determined by searching for a series of decreasingly
189
- specific name patterns. When creating a new template with
190
- `Tilt.new('views/foo.html.erb')`, we check for the following template
191
- mappings:
192
-
193
- 1. `views/foo.html.erb`
194
- 2. `foo.html.erb`
195
- 3. `html.erb`
196
- 4. `erb`
197
-
198
- Encodings
199
- ---------
200
-
201
- Tilt needs to know the encoding of the template in order to work properly:
202
-
203
- Tilt will use `Encoding.default_external` as the encoding when reading external
204
- files. If you're mostly working with one encoding (e.g. UTF-8) we *highly*
205
- recommend setting this option. When providing a custom reader block (`Tilt.new
206
- { custom_string }`) you'll have ensure the string is properly encoded yourself.
207
-
208
- Most of the template engines in Tilt also allows you to override the encoding
209
- using the `:default_encoding`-option:
210
-
211
- ```ruby
212
- tmpl = Tilt.new('hello.erb', :default_encoding => 'Big5')
213
- ```
214
-
215
- Ultimately it's up to the template engine how to handle the encoding: It might
216
- respect `:default_encoding`, it might always assume it's UTF-8 (like
217
- CoffeeScript), or it can do its own encoding detection.
218
-
219
- Template Compilation
220
- --------------------
221
-
222
- Tilt compiles generated Ruby source code produced by template engines and reuses
223
- it on subsequent template invocations. Benchmarks show this yields a 5x-10x
224
- performance increase over evaluating the Ruby source on each invocation.
225
-
226
- Template compilation is currently supported for these template engines:
227
- StringTemplate, ERB, Erubis, Haml, Nokogiri, Builder and Yajl.
228
-
229
- LICENSE
230
- -------
231
-
232
- Tilt is Copyright (c) 2010 [Ryan Tomayko](http://tomayko.com/about) and
233
- distributed under the MIT license. See the `COPYING` file for more info.