tilt 2.0.8 → 2.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tilt/commonmarker.rb +68 -1
  3. data/lib/tilt/csv.rb +1 -1
  4. data/lib/tilt/erb.rb +7 -1
  5. data/lib/tilt/haml.rb +2 -2
  6. data/lib/tilt/pandoc.rb +23 -15
  7. data/lib/tilt/redcarpet.rb +5 -2
  8. data/lib/tilt/rst-pandoc.rb +12 -7
  9. data/lib/tilt/sass.rb +40 -3
  10. data/lib/tilt/template.rb +18 -12
  11. data/lib/tilt.rb +2 -1
  12. metadata +8 -110
  13. data/CHANGELOG.md +0 -127
  14. data/Gemfile +0 -65
  15. data/HACKING +0 -16
  16. data/README.md +0 -233
  17. data/Rakefile +0 -106
  18. data/docs/TEMPLATES.md +0 -555
  19. data/docs/common.css +0 -14
  20. data/man/index.txt +0 -2
  21. data/man/tilt.1.ronn +0 -59
  22. data/test/markaby/locals.mab +0 -1
  23. data/test/markaby/markaby.mab +0 -1
  24. data/test/markaby/markaby_other_static.mab +0 -1
  25. data/test/markaby/render_twice.mab +0 -1
  26. data/test/markaby/scope.mab +0 -1
  27. data/test/markaby/yielding.mab +0 -2
  28. data/test/mytemplate.rb +0 -2
  29. data/test/test_helper.rb +0 -64
  30. data/test/tilt_asciidoctor_test.rb +0 -50
  31. data/test/tilt_babeltemplate.rb +0 -33
  32. data/test/tilt_blueclothtemplate_test.rb +0 -33
  33. data/test/tilt_buildertemplate_test.rb +0 -72
  34. data/test/tilt_cache_test.rb +0 -43
  35. data/test/tilt_coffeescripttemplate_test.rb +0 -141
  36. data/test/tilt_commonmarkertemplate_test.rb +0 -20
  37. data/test/tilt_compilesite_test.rb +0 -51
  38. data/test/tilt_creoletemplate_test.rb +0 -24
  39. data/test/tilt_csv_test.rb +0 -77
  40. data/test/tilt_erbtemplate_test.rb +0 -239
  41. data/test/tilt_erubistemplate_test.rb +0 -151
  42. data/test/tilt_erubitemplate_test.rb +0 -158
  43. data/test/tilt_etannitemplate_test.rb +0 -174
  44. data/test/tilt_hamltemplate_test.rb +0 -166
  45. data/test/tilt_kramdown_test.rb +0 -20
  46. data/test/tilt_lesstemplate_test.less +0 -1
  47. data/test/tilt_lesstemplate_test.rb +0 -42
  48. data/test/tilt_liquidtemplate_test.rb +0 -87
  49. data/test/tilt_livescripttemplate_test.rb +0 -37
  50. data/test/tilt_mapping_test.rb +0 -232
  51. data/test/tilt_markaby_test.rb +0 -88
  52. data/test/tilt_markdown_test.rb +0 -186
  53. data/test/tilt_marukutemplate_test.rb +0 -36
  54. data/test/tilt_metadata_test.rb +0 -42
  55. data/test/tilt_nokogiritemplate_test.rb +0 -87
  56. data/test/tilt_pandoctemplate_test.rb +0 -67
  57. data/test/tilt_prawntemplate.prawn +0 -1
  58. data/test/tilt_prawntemplate_test.rb +0 -75
  59. data/test/tilt_radiustemplate_test.rb +0 -75
  60. data/test/tilt_rdiscounttemplate_test.rb +0 -43
  61. data/test/tilt_rdoctemplate_test.rb +0 -29
  62. data/test/tilt_redcarpettemplate_test.rb +0 -54
  63. data/test/tilt_redclothtemplate_test.rb +0 -36
  64. data/test/tilt_rstpandoctemplate_test.rb +0 -32
  65. data/test/tilt_sasstemplate_test.rb +0 -41
  66. data/test/tilt_sigil_test.rb +0 -41
  67. data/test/tilt_stringtemplate_test.rb +0 -171
  68. data/test/tilt_template_test.rb +0 -314
  69. data/test/tilt_test.rb +0 -60
  70. data/test/tilt_typescript_test.rb +0 -38
  71. data/test/tilt_wikiclothtemplate_test.rb +0 -32
  72. data/test/tilt_yajltemplate_test.rb +0 -101
  73. data/tilt.gemspec +0 -130
data/Gemfile DELETED
@@ -1,65 +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
- gem 'sass'
21
-
22
- if can_execjs
23
- gem 'less'
24
- gem 'coffee-script'
25
- gem 'livescript'
26
- gem 'babel-transpiler'
27
- gem 'typescript-node'
28
- end
29
- end
30
-
31
- platform :mri do
32
- gem 'duktape', '~> 1.3.0.6' if can_execjs
33
- end
34
-
35
- group :secondary do
36
- gem 'creole'
37
- gem 'kramdown'
38
- gem 'rdoc'
39
- gem 'radius'
40
- gem 'asciidoctor', '>= 0.1.0'
41
- gem 'liquid'
42
- gem 'maruku'
43
- gem 'pandoc-ruby'
44
-
45
- if RUBY_VERSION > '1.9.3'
46
- gem 'prawn', '>= 2.0.0'
47
- gem 'pdf-reader', '~> 1.3.3'
48
- end
49
-
50
- gem 'nokogiri' if RUBY_VERSION > '1.9.2'
51
-
52
- platform :ruby do
53
- gem 'wikicloth'
54
- gem 'yajl-ruby'
55
- gem 'redcarpet' if RUBY_VERSION > '1.8.7'
56
- gem 'rdiscount', '>= 2.1.6' if RUBY_VERSION != '1.9.2'
57
- gem 'RedCloth'
58
- gem 'commonmarker' if RUBY_VERSION > '1.9.3'
59
- end
60
-
61
- platform :mri do
62
- gem 'bluecloth'
63
- end
64
- end
65
-
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) [![Dependency Status](https://gemnasium.com/rtomayko/tilt.svg)](https://gemnasium.com/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.
data/Rakefile DELETED
@@ -1,106 +0,0 @@
1
- require 'bundler'
2
- Bundler.setup
3
-
4
- require 'rake/testtask'
5
- task :default => [:test]
6
-
7
- # SPECS =====================================================================
8
-
9
- desc 'Run tests (default)'
10
- Rake::TestTask.new(:test) do |t|
11
- t.test_files = FileList['test/*_test.rb']
12
- t.ruby_opts = ['-Itest']
13
- t.ruby_opts << '-rubygems' if defined? Gem
14
- t.warning = false
15
- end
16
-
17
- # DOCUMENTATION =============================================================
18
-
19
- begin
20
- require 'yard'
21
- YARD::Rake::YardocTask.new do |t|
22
- t.files = [
23
- 'lib/tilt.rb', 'lib/tilt/mapping.rb', 'lib/tilt/template.rb',
24
- '-',
25
- '*.md', 'docs/*.md',
26
- ]
27
-
28
- t.options <<
29
- '--no-private' <<
30
- '--protected' <<
31
- '-m' << 'markdown' <<
32
- '--asset' << 'docs/common.css:css/common.css'
33
- end
34
- rescue LoadError
35
- end
36
-
37
- task :man do
38
- require 'ronn'
39
- ENV['RONN_MANUAL'] = "Tilt Manual"
40
- ENV['RONN_ORGANIZATION'] = "Tilt #{SPEC.version}"
41
- sh "ronn -w -s toc -r5 --markdown man/*.ronn"
42
- end
43
-
44
- # PACKAGING =================================================================
45
-
46
- begin
47
- require 'rubygems'
48
- rescue LoadError
49
- end
50
-
51
- if defined?(Gem)
52
- SPEC = eval(File.read('tilt.gemspec'))
53
-
54
- def package(ext='')
55
- "pkg/tilt-#{SPEC.version}" + ext
56
- end
57
-
58
- desc 'Build packages'
59
- task :package => %w[.gem .tar.gz].map {|e| package(e)}
60
-
61
- desc 'Build and install as local gem'
62
- task :install => package('.gem') do
63
- sh "gem install #{package('.gem')}"
64
- end
65
-
66
- directory 'pkg/'
67
-
68
- file package('.gem') => %w[pkg/ tilt.gemspec] + SPEC.files do |f|
69
- sh "gem build tilt.gemspec"
70
- mv File.basename(f.name), f.name
71
- end
72
-
73
- file package('.tar.gz') => %w[pkg/] + SPEC.files do |f|
74
- sh "git archive --format=tar HEAD | gzip > #{f.name}"
75
- end
76
-
77
- desc 'Upload gem and tar.gz distributables to rubyforge'
78
- task :release => [package('.gem'), package('.tar.gz')] do |t|
79
- sh <<-SH
80
- rubyforge add_release sinatra tilt #{SPEC.version} #{package('.gem')} &&
81
- rubyforge add_file sinatra tilt #{SPEC.version} #{package('.tar.gz')}
82
- SH
83
- end
84
- end
85
-
86
- # GEMSPEC ===================================================================
87
-
88
- file 'tilt.gemspec' => FileList['{lib,test}/**','Rakefile'] do |f|
89
- # read version from tilt.rb
90
- version = File.read('lib/tilt.rb')[/VERSION = '(.*)'/] && $1
91
- # read spec file and split out manifest section
92
- spec = File.
93
- read(f.name).
94
- sub(/s\.version\s*=\s*'.*'/, "s.version = '#{version}'")
95
- parts = spec.split(" # = MANIFEST =\n")
96
- # determine file list from git ls-files
97
- files = `git ls-files`.
98
- split("\n").sort.reject{ |file| file =~ /^\./ }.
99
- map{ |file| " #{file}" }.join("\n")
100
- # piece file back together and write...
101
- parts[1] = " s.files = %w[\n#{files}\n ]\n"
102
- spec = parts.join(" # = MANIFEST =\n")
103
- spec.sub!(/s.date = '.*'/, "s.date = '#{Time.now.strftime("%Y-%m-%d")}'")
104
- File.open(f.name, 'w') { |io| io.write(spec) }
105
- puts "updated #{f.name}"
106
- end