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
@@ -1,14 +0,0 @@
1
- body {
2
- line-height: 1.5;
3
- font-size: 14px;
4
- }
5
-
6
- .frames #content {
7
- margin: 0;
8
- }
9
-
10
- #content {
11
- margin: 0 auto;
12
- max-width: 720px;
13
- }
14
-
@@ -1,2 +0,0 @@
1
- m4(1) http://man.cx/m4(1)
2
- mustache(1) https://mustache.github.io/mustache.1.html
@@ -1,59 +0,0 @@
1
- tilt(1) -- process templates
2
- ============================
3
-
4
- ## SYNOPSIS
5
-
6
- `tilt` `-l`<br>
7
- `tilt` [`-t` <pattern>] [`-y` <file>] [`-D` <name>=<value>] [`-d` <file>]
8
- [`--vars=`<ruby>] <file>
9
-
10
- ## DESCRIPTION
11
-
12
- Process template <file> and write output to stdout. With no <file> or
13
- when <file> is '-', read template from stdin and use the --type option
14
- to determine the template's type.
15
-
16
- ## OPTIONS
17
-
18
- * `-l`, `--list`:
19
- List template engines + file patterns and exit
20
- * `-t`, `--type`=<pattern>:
21
- Use this template engine; required if no <file>
22
- * `-y`, `--layout`=<file>:
23
- Use <file> as a layout template
24
- * `-D`<name>=<value>:
25
- Define variable <name> as <value>
26
- * `-d`, `--define-file`=<file>:
27
- Load YAML or JSON from <file> and use for variables
28
- * `--vars`=<ruby>:
29
- Evaluate <ruby> to Hash and use for variables
30
- * `-h`, `--help`:
31
- Show this help message
32
-
33
- ## EXAMPLES
34
-
35
- Convert markdown to HTML:
36
-
37
- $ tilt foo.markdown > foo.html
38
-
39
- Process ERB template:
40
-
41
- $ echo "Answer: <%= 2 + 2 %>" | tilt -t erb
42
- Answer: 4
43
-
44
- Define variables:
45
-
46
- $ echo '{"n":40}' > data.json
47
- $ echo "Answer: <%= 2 + n %>" | tilt -t erb -d data.json
48
- Answer: 42
49
-
50
- $ echo "Answer: <%= 2 + n %>" | tilt -t erb --vars="{:n=>40}"
51
- Answer: 42
52
- $ echo "Answer: <%= 2 + n.to_i %>" | tilt -t erb -Dn=40
53
- Answer: 42
54
-
55
- ## SEE ALSO
56
-
57
- m4(1), mustache(1)
58
-
59
-
@@ -1 +0,0 @@
1
- li foo
@@ -1 +0,0 @@
1
- text "hello from markaby!"
@@ -1 +0,0 @@
1
- text "_why?"
@@ -1 +0,0 @@
1
- text "foo"
@@ -1 +0,0 @@
1
- li foo
@@ -1,2 +0,0 @@
1
- text("Hey ")
2
- yield
@@ -1,2 +0,0 @@
1
- class MyTemplate
2
- end
@@ -1,64 +0,0 @@
1
- $LOAD_PATH << File.expand_path('../../lib', __FILE__)
2
-
3
- require 'bundler'
4
- Bundler.setup
5
-
6
- require 'minitest/autorun'
7
- require 'minitest/mock'
8
-
9
- # Contest adds +teardown+, +test+ and +context+ as class methods, and the
10
- # instance methods +setup+ and +teardown+ now iterate on the corresponding
11
- # blocks. Note that all setup and teardown blocks must be defined with the
12
- # block syntax. Adding setup or teardown instance methods defeats the purpose
13
- # of this library.
14
- class Minitest::Test
15
- def self.setup(&block)
16
- define_method :setup do
17
- super(&block)
18
- instance_eval(&block)
19
- end
20
- end
21
-
22
- def self.teardown(&block)
23
- define_method :teardown do
24
- instance_eval(&block)
25
- super(&block)
26
- end
27
- end
28
-
29
- def self.context(name, &block)
30
- subclass = Class.new(self)
31
- remove_tests(subclass)
32
- subclass.class_eval(&block) if block_given?
33
- const_set(context_name(name), subclass)
34
- end
35
-
36
- def self.test(name, &block)
37
- define_method(test_name(name), &block)
38
- end
39
-
40
- class << self
41
- alias_method :should, :test
42
- alias_method :describe, :context
43
- end
44
-
45
- private
46
-
47
- def self.context_name(name)
48
- "Test#{sanitize_name(name).gsub(/(^| )(\w)/) { $2.upcase }}".to_sym
49
- end
50
-
51
- def self.test_name(name)
52
- "test_#{sanitize_name(name).gsub(/\s+/,'_')}".to_sym
53
- end
54
-
55
- def self.sanitize_name(name)
56
- name.gsub(/\W+/, ' ').strip
57
- end
58
-
59
- def self.remove_tests(subclass)
60
- subclass.public_instance_methods.grep(/^test_/).each do |meth|
61
- subclass.send(:undef_method, meth.to_sym)
62
- end
63
- end
64
- end
@@ -1,50 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- begin
5
- require 'tilt/asciidoc'
6
-
7
- class AsciidoctorTemplateTest < Minitest::Test
8
- HTML5_OUTPUT = "<div class=\"sect1\"><h2 id=\"_hello_world\">Hello World!</h2><div class=\"sectionbody\"></div></div>"
9
- DOCBOOK45_OUTPUT = "<section id=\"_hello_world\"><title>Hello World!</title></section>"
10
- DOCBOOK5_OUTPUT = "<section xml:id=\"_hello_world\"><title>Hello World!</title></section>"
11
-
12
- def strip_space(str)
13
- str.gsub(/>\s+</, '><').strip
14
- end
15
-
16
- test "registered for '.ad' files" do
17
- assert_equal Tilt::AsciidoctorTemplate, Tilt['ad']
18
- end
19
-
20
- test "registered for '.adoc' files" do
21
- assert_equal Tilt::AsciidoctorTemplate, Tilt['adoc']
22
- end
23
-
24
- test "registered for '.asciidoc' files" do
25
- assert_equal Tilt::AsciidoctorTemplate, Tilt['asciidoc']
26
- end
27
-
28
- test "preparing and evaluating html5 templates on #render" do
29
- template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'html5'}) { |t| "== Hello World!" }
30
- assert_equal HTML5_OUTPUT, strip_space(template.render)
31
- end
32
-
33
- test "preparing and evaluating docbook 4.5 templates on #render" do
34
- template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook45'}) { |t| "== Hello World!" }
35
- assert_equal DOCBOOK45_OUTPUT, strip_space(template.render)
36
- end
37
-
38
- test "preparing and evaluating docbook 5 templates on #render" do
39
- template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'docbook5'}) { |t| "== Hello World!" }
40
- assert_equal DOCBOOK5_OUTPUT, strip_space(template.render)
41
- end
42
-
43
- test "can be rendered more than once" do
44
- template = Tilt::AsciidoctorTemplate.new(:attributes => {"backend" => 'html5'}) { |t| "== Hello World!" }
45
- 3.times { assert_equal HTML5_OUTPUT, strip_space(template.render) }
46
- end
47
- end
48
- rescue LoadError
49
- warn "Tilt::AsciidoctorTemplate (disabled)"
50
- end
@@ -1,33 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- begin
5
- require 'tilt/babel'
6
-
7
- class BabelTemplateTest < Minitest::Test
8
- test "registered for '.es6' files" do
9
- assert_equal Tilt::BabelTemplate, Tilt['es6']
10
- end
11
-
12
- test "registered for '.babel' files" do
13
- assert_equal Tilt::BabelTemplate, Tilt['babel']
14
- end
15
-
16
- test "registered for '.jsx' files" do
17
- assert_equal Tilt::BabelTemplate, Tilt['jsx']
18
- end
19
-
20
- test "basic ES6 features" do
21
- template = Tilt::BabelTemplate.new { "square = (x) => x * x" }
22
- assert_match "function", template.render
23
- end
24
-
25
- test "JSX support" do
26
- template = Tilt::BabelTemplate.new { "<Awesome ness={true} />" }
27
- assert_match "React.createElement", template.render
28
- end
29
- end
30
- rescue LoadError => boom
31
- warn "Tilt::BabelTemplate (disabled)"
32
- end
33
-
@@ -1,33 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- begin
5
- require 'tilt/bluecloth'
6
-
7
- class BlueClothTemplateTest < Minitest::Test
8
- test "preparing and evaluating templates on #render" do
9
- template = Tilt::BlueClothTemplate.new { |t| "# Hello World!" }
10
- assert_equal "<h1>Hello World!</h1>", template.render
11
- end
12
-
13
- test "can be rendered more than once" do
14
- template = Tilt::BlueClothTemplate.new { |t| "# Hello World!" }
15
- 3.times { assert_equal "<h1>Hello World!</h1>", template.render }
16
- end
17
-
18
- test "smartypants when :smart is set" do
19
- template = Tilt::BlueClothTemplate.new(:smartypants => true) { |t|
20
- "OKAY -- 'Smarty Pants'" }
21
- assert_equal "<p>OKAY &mdash; &lsquo;Smarty Pants&rsquo;</p>",
22
- template.render
23
- end
24
-
25
- test "stripping HTML when :filter_html is set" do
26
- template = Tilt::BlueClothTemplate.new(:escape_html => true) { |t|
27
- "HELLO <blink>WORLD</blink>" }
28
- assert_equal "<p>HELLO &lt;blink>WORLD&lt;/blink></p>", template.render
29
- end
30
- end
31
- rescue LoadError
32
- warn "Tilt::BlueClothTemplate (disabled)"
33
- end
@@ -1,72 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- begin
5
- require 'tilt/builder'
6
- class BuilderTemplateTest < Minitest::Test
7
- test "registered for '.builder' files" do
8
- assert_equal Tilt::BuilderTemplate, Tilt['test.builder']
9
- assert_equal Tilt::BuilderTemplate, Tilt['test.xml.builder']
10
- end
11
-
12
- test "preparing and evaluating the template on #render" do
13
- template = Tilt::BuilderTemplate.new { |t| "xml.em 'Hello World!'" }
14
- assert_equal "<em>Hello World!</em>\n", template.render
15
- end
16
-
17
- test "can be rendered more than once" do
18
- template = Tilt::BuilderTemplate.new { |t| "xml.em 'Hello World!'" }
19
- 3.times { assert_equal "<em>Hello World!</em>\n", template.render }
20
- end
21
-
22
- test "passing locals" do
23
- template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + name + '!')" }
24
- assert_equal "<em>Hey Joe!</em>\n", template.render(Object.new, :name => 'Joe')
25
- end
26
-
27
- test "evaluating in an object scope" do
28
- template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + @name + '!')" }
29
- scope = Object.new
30
- scope.instance_variable_set :@name, 'Joe'
31
- assert_equal "<em>Hey Joe!</em>\n", template.render(scope)
32
- end
33
-
34
- test "passing a block for yield" do
35
- template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + yield + '!')" }
36
- 3.times { assert_equal "<em>Hey Joe!</em>\n", template.render { 'Joe' }}
37
- end
38
-
39
- test "block style templates" do
40
- template =
41
- Tilt::BuilderTemplate.new do |t|
42
- lambda { |xml| xml.em('Hey Joe!') }
43
- end
44
- assert_equal "<em>Hey Joe!</em>\n", template.render
45
- end
46
-
47
- test "options can be overridden" do
48
- template = Tilt::BuilderTemplate.new(:indent => 0) { "xml.div { xml.em('Hey') }" }
49
- assert_equal "<div><em>Hey</em></div>", template.render
50
- end
51
-
52
- test "can re-use locals for multiple calls" do
53
- locals = { :name => "world" }
54
- template = Tilt::BuilderTemplate.new(:indent => 0) { "xml.em name" }
55
- 3.times do
56
- assert_equal "<em>world</em>", template.render(self, locals)
57
- end
58
- end
59
-
60
- test "allows nesting raw XML" do
61
- subtemplate = Tilt::BuilderTemplate.new { "xml.em 'Hello World!'" }
62
- template = Tilt::BuilderTemplate.new { "xml.strong { xml << yield }" }
63
- 3.times do
64
- options = { :xml => Builder::XmlMarkup.new }
65
- assert_equal "<strong>\n<em>Hello World!</em>\n</strong>\n",
66
- template.render(options) { subtemplate.render(options) }
67
- end
68
- end
69
- end
70
- rescue LoadError
71
- warn "Tilt::BuilderTemplate (disabled)"
72
- end
@@ -1,43 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- class TiltCacheTest < Minitest::Test
5
- setup { @cache = Tilt::Cache.new }
6
-
7
- test "caching with single simple argument to #fetch" do
8
- template = nil
9
- result = @cache.fetch('hello') { template = Tilt::StringTemplate.new {''} }
10
- assert_same template, result
11
- result = @cache.fetch('hello') { fail 'should be cached' }
12
- assert_same template, result
13
- end
14
-
15
- test "caching with multiple complex arguments to #fetch" do
16
- template = nil
17
- result = @cache.fetch('hello', {:foo => 'bar', :baz => 'bizzle'}) { template = Tilt::StringTemplate.new {''} }
18
- assert_same template, result
19
- result = @cache.fetch('hello', {:foo => 'bar', :baz => 'bizzle'}) { fail 'should be cached' }
20
- assert_same template, result
21
- end
22
-
23
- test "caching nil" do
24
- called = false
25
- result = @cache.fetch("blah") {called = true; nil}
26
- assert_equal true, called
27
- assert_nil result
28
- called = false
29
- result = @cache.fetch("blah") {called = true; :blah}
30
- assert_equal false, called
31
- assert_nil result
32
- end
33
-
34
- test "clearing the cache with #clear" do
35
- template, other = nil
36
- result = @cache.fetch('hello') { template = Tilt::StringTemplate.new {''} }
37
- assert_same template, result
38
-
39
- @cache.clear
40
- result = @cache.fetch('hello') { other = Tilt::StringTemplate.new {''} }
41
- assert_same other, result
42
- end
43
- end
@@ -1,141 +0,0 @@
1
- require 'test_helper'
2
- require 'tilt'
3
-
4
- begin
5
- require 'tilt/coffee'
6
-
7
- module CoffeeScriptTests
8
- def self.included(mod)
9
- mod.class_eval do
10
- test "bare is disabled by default" do
11
- assert_equal false, @renderer.default_bare
12
- end
13
-
14
- test "compiles and evaluates the template on #render" do
15
- template = @renderer.new { |t| @code_without_variables }
16
- assert_match "puts('Hello, World!');", template.render
17
- end
18
-
19
- test "can be rendered more than once" do
20
- template = @renderer.new { |t| @code_without_variables }
21
- 3.times { assert_match "puts('Hello, World!');", template.render }
22
- end
23
-
24
- test "disabling coffee-script wrapper" do
25
- template = @renderer.new { @code_with_variables }
26
- assert_match "(function() {", template.render
27
- assert_match "puts(\"Hello, \" + name);\n", template.render
28
-
29
- template = @renderer.new(:bare => true) { @code_with_variables }
30
- refute_match "(function() {", template.render
31
- assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello, \" + name);\n", template.render
32
-
33
- template = @renderer.new(:no_wrap => true) { @code_with_variables}
34
- refute_match "(function() {", template.render
35
- assert_equal "var name;\n\nname = \"Josh\";\n\nputs(\"Hello, \" + name);\n", template.render
36
- end
37
-
38
- context "wrapper globally enabled" do
39
- setup do
40
- @bare = @renderer.default_bare
41
- @renderer.default_bare = false
42
- end
43
-
44
- teardown do
45
- @renderer.default_bare = @bare
46
- end
47
-
48
- test "no options" do
49
- template = @renderer.new { |t| @code_with_variables }
50
- assert_match "puts(\"Hello, \" + name);", template.render
51
- assert_match "(function() {", template.render
52
- end
53
-
54
- test "overridden by :bare" do
55
- template = @renderer.new(:bare => true) { |t| @code_with_variables }
56
- assert_match "puts(\"Hello, \" + name);", template.render
57
- refute_match "(function() {", template.render
58
- end
59
-
60
- test "overridden by :no_wrap" do
61
- template = @renderer.new(:no_wrap => true) { |t| @code_with_variables }
62
- assert_match "puts(\"Hello, \" + name);", template.render
63
- refute_match "(function() {", template.render
64
- end
65
- end
66
-
67
- context "wrapper globally disabled" do
68
- setup do
69
- @bare = @renderer.default_bare
70
- @renderer.default_bare = true
71
- end
72
-
73
- teardown do
74
- @renderer.default_bare = @bare
75
- end
76
-
77
- test "no options" do
78
- template = @renderer.new { |t| @code_with_variables }
79
- assert_match "puts(\"Hello, \" + name);", template.render
80
- refute_match "(function() {", template.render
81
- end
82
-
83
- test "overridden by :bare" do
84
- template = @renderer.new(:bare => false) { |t| @code_with_variables }
85
- assert_match "puts(\"Hello, \" + name);", template.render
86
- assert_match "(function() {", template.render
87
- end
88
-
89
- test "overridden by :no_wrap" do
90
- template = @renderer.new(:no_wrap => false) { |t| @code_with_variables }
91
- assert_match "puts(\"Hello, \" + name);", template.render
92
- assert_match "(function() {", template.render
93
- end
94
- end
95
- end
96
- end
97
- end
98
-
99
- class CoffeeScriptTemplateTest < Minitest::Test
100
- setup do
101
- @code_without_variables = "puts 'Hello, World!'\n"
102
- @code_with_variables = 'name = "Josh"; puts "Hello, #{name}"'
103
- @renderer = Tilt::CoffeeScriptTemplate
104
- end
105
-
106
- include CoffeeScriptTests
107
-
108
- test "is registered for '.coffee' files" do
109
- assert_equal @renderer, Tilt['test.coffee']
110
- end
111
- end
112
-
113
- class LiterateCoffeeScriptTemplateTest < Minitest::Test
114
- setup do
115
- @code_without_variables = <<EOLIT
116
- This is some comment.
117
-
118
- puts 'Hello, World!'
119
-
120
- This is a comment too.
121
- EOLIT
122
- @code_with_variables = <<EOLIT
123
- This is some comment.
124
-
125
- name = "Josh"; puts "Hello, \#{name}"
126
-
127
- This is a comment too.
128
- EOLIT
129
- @renderer = Tilt::CoffeeScriptLiterateTemplate
130
- end
131
-
132
- include CoffeeScriptTests
133
-
134
- test "is registered for '.litcoffee' files" do
135
- assert_equal @renderer, Tilt['test.litcoffee']
136
- end
137
- end
138
-
139
- rescue LoadError
140
- warn "Tilt::CoffeeScriptTemplate (disabled)"
141
- end