tilt 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tilt/asciidoc.rb +12 -5
- data/lib/tilt/babel.rb +5 -0
- data/lib/tilt/builder.rb +4 -0
- data/lib/tilt/coffee.rb +14 -4
- data/lib/tilt/commonmarker.rb +41 -0
- data/lib/tilt/csv.rb +35 -25
- data/lib/tilt/erb.rb +67 -2
- data/lib/tilt/erubi.rb +41 -8
- data/lib/tilt/etanni.rb +7 -0
- data/lib/tilt/haml.rb +67 -1
- data/lib/tilt/kramdown.rb +47 -1
- data/lib/tilt/liquid.rb +66 -10
- data/lib/tilt/livescript.rb +11 -4
- data/lib/tilt/mapping.rb +8 -8
- data/lib/tilt/markaby.rb +11 -2
- data/lib/tilt/nokogiri.rb +13 -2
- data/lib/tilt/pandoc.rb +43 -1
- data/lib/tilt/pipeline.rb +6 -1
- data/lib/tilt/plain.rb +5 -1
- data/lib/tilt/prawn.rb +17 -6
- data/lib/tilt/radius.rb +55 -0
- data/lib/tilt/rdiscount.rb +65 -6
- data/lib/tilt/rdoc.rb +23 -1
- data/lib/tilt/redcarpet.rb +42 -0
- data/lib/tilt/redcloth.rb +28 -1
- data/lib/tilt/rst-pandoc.rb +24 -1
- data/lib/tilt/sass.rb +16 -3
- data/lib/tilt/slim.rb +13 -0
- data/lib/tilt/string.rb +10 -2
- data/lib/tilt/template.rb +5 -5
- data/lib/tilt/typescript.rb +5 -0
- data/lib/tilt/yajl.rb +46 -36
- data/lib/tilt.rb +1 -2
- metadata +3 -3
- data/lib/tilt/creole.rb +0 -16
data/lib/tilt/pandoc.rb
CHANGED
|
@@ -1,8 +1,50 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Markdown (<tt>markdown</tt>, <tt>md</tt>, <tt>mkd</tt>)
|
|
4
|
+
#
|
|
5
|
+
# {Markdown}[http://daringfireball.net/projects/markdown/syntax] is a
|
|
6
|
+
# lightweight markup language, created by John Gruber and Aaron Swartz.
|
|
7
|
+
# For any markup that is not covered by Markdown’s syntax, HTML is used.
|
|
8
|
+
# Marking up plain text with Markdown markup is easy and Markdown
|
|
9
|
+
# formatted texts are readable.
|
|
10
|
+
#
|
|
11
|
+
# === Example
|
|
12
|
+
#
|
|
13
|
+
# Hello Markdown Templates
|
|
14
|
+
# ========================
|
|
15
|
+
#
|
|
16
|
+
# Hello World. This is a paragraph.
|
|
17
|
+
#
|
|
18
|
+
# === Usage
|
|
19
|
+
#
|
|
20
|
+
# To wrap a Markdown formatted document with a layout:
|
|
21
|
+
#
|
|
22
|
+
# layout = Tilt['erb'].new do
|
|
23
|
+
# "<!doctype html><title></title><%= yield %>"
|
|
24
|
+
# end
|
|
25
|
+
# data = Tilt['md'].new { "# hello tilt" }
|
|
26
|
+
# layout.render { data.render }
|
|
27
|
+
# # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
|
|
28
|
+
#
|
|
29
|
+
# === Options
|
|
30
|
+
#
|
|
31
|
+
# ==== <tt>:smartypants => true|false</tt>
|
|
32
|
+
#
|
|
33
|
+
# Set <tt>true</tt> to enable [Smarty Pants][smartypants] style punctuation replacement.
|
|
34
|
+
#
|
|
35
|
+
# ==== <tt>:escape_html => true|false</tt>
|
|
36
|
+
#
|
|
37
|
+
# Set <tt>true</tt> disallow raw HTML in Markdown contents. HTML is converted to
|
|
38
|
+
# literal text by escaping <tt><</tt> characters.
|
|
39
|
+
#
|
|
40
|
+
# === See also
|
|
41
|
+
#
|
|
42
|
+
# * {Markdown Syntax Documentation}[http://daringfireball.net/projects/markdown/syntax]
|
|
43
|
+
# * {Pandoc}[http://pandoc.org]
|
|
44
|
+
|
|
2
45
|
require_relative 'template'
|
|
3
46
|
require 'pandoc-ruby'
|
|
4
47
|
|
|
5
|
-
# Pandoc markdown implementation. See: http://pandoc.org/
|
|
6
48
|
Tilt::PandocTemplate = Tilt::StaticTemplate.subclass do
|
|
7
49
|
# turn options hash into an array
|
|
8
50
|
# Map tilt options to pandoc options
|
data/lib/tilt/pipeline.rb
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require_relative 'template'
|
|
3
4
|
|
|
4
5
|
module Tilt
|
|
5
6
|
# Superclass used for pipeline templates. Should not be used directly.
|
|
6
7
|
class Pipeline < Template
|
|
7
8
|
def prepare
|
|
8
|
-
@pipeline = self.class::TEMPLATES.inject(proc{|*| data}) do |data, (klass, options)|
|
|
9
|
+
@pipeline = self.class::TEMPLATES.inject(proc{|*| data}) do |data, (klass, ext, options)|
|
|
9
10
|
proc do |s,l,&sb|
|
|
11
|
+
options = options
|
|
12
|
+
if ext_opts = @options[ext]
|
|
13
|
+
options = options.merge(ext_opts)
|
|
14
|
+
end
|
|
10
15
|
klass.new(file, line, options, &proc{|*| data.call(s, l, &sb)}).render(s, l, &sb)
|
|
11
16
|
end
|
|
12
17
|
end
|
data/lib/tilt/plain.rb
CHANGED
data/lib/tilt/prawn.rb
CHANGED
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Prawn
|
|
4
|
+
#
|
|
5
|
+
# Prawn template implementation.
|
|
6
|
+
#
|
|
7
|
+
# === See also
|
|
8
|
+
#
|
|
9
|
+
# * http://prawnpdf.org
|
|
10
|
+
#
|
|
11
|
+
# === Related module
|
|
12
|
+
#
|
|
13
|
+
# * Tilt::PrawnTemplate
|
|
14
|
+
|
|
2
15
|
require_relative 'template'
|
|
3
16
|
require 'prawn'
|
|
4
17
|
|
|
5
18
|
module Tilt
|
|
6
|
-
# Prawn template implementation. See: http://prawnpdf.org
|
|
7
19
|
class PrawnTemplate < Template
|
|
8
20
|
self.default_mime_type = 'application/pdf'
|
|
9
|
-
|
|
21
|
+
|
|
10
22
|
def prepare
|
|
11
23
|
@options[:page_size] = 'A4' unless @options.has_key?(:page_size)
|
|
12
24
|
@options[:page_layout] = :portrait unless @options.has_key?(:page_layout)
|
|
13
|
-
@engine = ::Prawn::Document.new(@options)
|
|
14
25
|
end
|
|
15
|
-
|
|
26
|
+
|
|
16
27
|
def evaluate(scope, locals, &block)
|
|
17
|
-
pdf = @
|
|
28
|
+
pdf = ::Prawn::Document.new(@options)
|
|
18
29
|
locals = locals.dup
|
|
19
30
|
locals[:pdf] = pdf
|
|
20
31
|
super
|
|
21
32
|
pdf.render
|
|
22
33
|
end
|
|
23
|
-
|
|
34
|
+
|
|
24
35
|
def precompiled_template(locals)
|
|
25
36
|
@data.to_str
|
|
26
37
|
end
|
data/lib/tilt/radius.rb
CHANGED
|
@@ -1,4 +1,59 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Radius (<tt>radius</tt>)
|
|
4
|
+
#
|
|
5
|
+
# {Radius}[http://radius.rubyforge.org] is the template language used by {Radiant CMS}[http://radiantcms.org]. It is
|
|
6
|
+
# a tag language designed to be valid XML/HTML.
|
|
7
|
+
#
|
|
8
|
+
# === Example
|
|
9
|
+
#
|
|
10
|
+
# <html>
|
|
11
|
+
# <body>
|
|
12
|
+
# <h1><r:title /></h1>
|
|
13
|
+
# <ul class="<r:type />">
|
|
14
|
+
# <r:repeat times="3">
|
|
15
|
+
# <li><r:hello />!</li>
|
|
16
|
+
# </r:repeat>
|
|
17
|
+
# </ul>
|
|
18
|
+
# <r:yield />
|
|
19
|
+
# </body>
|
|
20
|
+
# </html>
|
|
21
|
+
#
|
|
22
|
+
# === Usage
|
|
23
|
+
#
|
|
24
|
+
# To render a template such as the one above.
|
|
25
|
+
#
|
|
26
|
+
# scope = OpenStruct.new
|
|
27
|
+
# scope.title = "Radius Example"
|
|
28
|
+
# scope.hello = "Hello, World!"
|
|
29
|
+
#
|
|
30
|
+
# require 'radius'
|
|
31
|
+
# template = Tilt::RadiusTemplate.new('example.radius', :tag_prefix=>'r')
|
|
32
|
+
# template.render(scope, :type=>'hlist'){ "Jackpot!" }
|
|
33
|
+
#
|
|
34
|
+
# The result will be:
|
|
35
|
+
#
|
|
36
|
+
# <html>
|
|
37
|
+
# <body>
|
|
38
|
+
# <h1>Radius Example</h1>
|
|
39
|
+
# <ul class="hlist">
|
|
40
|
+
# <li>Hello, World!</li>
|
|
41
|
+
# <li>Hello, World!</li>
|
|
42
|
+
# <li>Hello, World!</li>
|
|
43
|
+
# </ul>
|
|
44
|
+
# Jackpot!
|
|
45
|
+
# </body>
|
|
46
|
+
# </html>
|
|
47
|
+
#
|
|
48
|
+
# === See also
|
|
49
|
+
#
|
|
50
|
+
# * {Radius}[http://radius.rubyforge.org]
|
|
51
|
+
# * {Radiant CMS}[http://radiantcms.org]
|
|
52
|
+
#
|
|
53
|
+
# === Related module
|
|
54
|
+
#
|
|
55
|
+
# * Tilt::RadiusTemplate
|
|
56
|
+
|
|
2
57
|
require_relative 'template'
|
|
3
58
|
require 'radius'
|
|
4
59
|
|
data/lib/tilt/rdiscount.rb
CHANGED
|
@@ -1,4 +1,69 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = RDiscount (<tt>markdown</tt>, <tt>md</tt>, <tt>mkd</tt>)
|
|
4
|
+
#
|
|
5
|
+
# Markdown is a lightweight markup language, created by John Gruber
|
|
6
|
+
# and Aaron Swartz. For any markup that is not covered by Markdown’s syntax, HTML
|
|
7
|
+
# is used. Marking up plain text with Markdown markup is easy and Markdown
|
|
8
|
+
# formatted texts are readable.
|
|
9
|
+
#
|
|
10
|
+
# RDiscount is a simple text filter. It does not support +scope+ or
|
|
11
|
+
# +locals+. The +:smart+ and +:filter_html+ options may be set true
|
|
12
|
+
# to enable those flags on the underlying RDiscount object.
|
|
13
|
+
#
|
|
14
|
+
# === Example
|
|
15
|
+
#
|
|
16
|
+
# Hello Markdown Templates
|
|
17
|
+
# ========================
|
|
18
|
+
#
|
|
19
|
+
# Hello World. This is a paragraph.
|
|
20
|
+
#
|
|
21
|
+
# === Usage
|
|
22
|
+
#
|
|
23
|
+
# To wrap a Markdown formatted document with a layout:
|
|
24
|
+
#
|
|
25
|
+
# layout = Tilt['erb'].new do
|
|
26
|
+
# "<!doctype html><title></title><%= yield %>"
|
|
27
|
+
# end
|
|
28
|
+
# data = Tilt['md'].new { "# hello tilt" }
|
|
29
|
+
# layout.render { data.render }
|
|
30
|
+
# # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
|
|
31
|
+
#
|
|
32
|
+
# === Options
|
|
33
|
+
#
|
|
34
|
+
# ==== <tt>:smartypants => true|false</tt>
|
|
35
|
+
#
|
|
36
|
+
# Set <tt>true</tt> to enable [Smarty Pants][smartypants] style punctuation replacement.
|
|
37
|
+
#
|
|
38
|
+
# ==== <tt>:escape_html => true|false</tt>
|
|
39
|
+
#
|
|
40
|
+
# Set <tt>true</tt> disallow raw HTML in Markdown contents. HTML is converted to
|
|
41
|
+
# literal text by escaping <tt><</tt> characters.
|
|
42
|
+
#
|
|
43
|
+
# === See also
|
|
44
|
+
#
|
|
45
|
+
# * {Markdown Syntax Documentation}[http://daringfireball.net/projects/markdown/syntax]
|
|
46
|
+
# * [Discount][discount]
|
|
47
|
+
# * {RDiscount}[http://github.com/rtomayko/rdiscount]
|
|
48
|
+
#
|
|
49
|
+
# -----------------------------------
|
|
50
|
+
#
|
|
51
|
+
# [Discount][discount] is an implementation of the Markdown markup language in C.
|
|
52
|
+
# [RDiscount][rdiscount] is a Ruby wrapper around Discount.
|
|
53
|
+
#
|
|
54
|
+
# All the documentation of {Markdown}[#markdown] applies in addition to the following:
|
|
55
|
+
#
|
|
56
|
+
# === Usage
|
|
57
|
+
#
|
|
58
|
+
# The <tt>Tilt::RDiscountTemplate</tt> class is registered for all files ending in
|
|
59
|
+
# <tt>.markdown</tt>, <tt>.md</tt> or <tt>.mkd</tt> by default with the highest priority. If you
|
|
60
|
+
# specifically want to use RDiscount, it's recommended to use <tt>#prefer</tt>:
|
|
61
|
+
#
|
|
62
|
+
# Tilt.prefer Tilt::RDiscountTemplate
|
|
63
|
+
#
|
|
64
|
+
# __NOTE:__ It's suggested that your program <tt>require 'rdiscount'</tt> at load time when
|
|
65
|
+
# using this template engine within a threaded environment.
|
|
66
|
+
|
|
2
67
|
require_relative 'template'
|
|
3
68
|
require 'rdiscount'
|
|
4
69
|
|
|
@@ -9,12 +74,6 @@ aliases = {
|
|
|
9
74
|
|
|
10
75
|
_flags = [:smart, :filter_html, :smartypants, :escape_html].freeze
|
|
11
76
|
|
|
12
|
-
# Discount Markdown implementation. See:
|
|
13
|
-
# http://github.com/rtomayko/rdiscount
|
|
14
|
-
#
|
|
15
|
-
# RDiscount is a simple text filter. It does not support +scope+ or
|
|
16
|
-
# +locals+. The +:smart+ and +:filter_html+ options may be set true
|
|
17
|
-
# to enable those flags on the underlying RDiscount object.
|
|
18
77
|
Tilt::RDiscountTemplate = Tilt::StaticTemplate.subclass do
|
|
19
78
|
flags = _flags.select { |flag| @options[flag] }.
|
|
20
79
|
map! { |flag| aliases[flag] || flag }
|
data/lib/tilt/rdoc.rb
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = RDoc (<tt>rdoc</tt>)
|
|
4
|
+
#
|
|
5
|
+
# {RDoc}[http://rdoc.rubyforge.org] is the simple text markup system that comes with Ruby's standard
|
|
6
|
+
# library.
|
|
7
|
+
#
|
|
8
|
+
# === Example
|
|
9
|
+
#
|
|
10
|
+
# = Hello RDoc Templates
|
|
11
|
+
#
|
|
12
|
+
# Hello World. This is a paragraph.
|
|
13
|
+
#
|
|
14
|
+
# === Usage
|
|
15
|
+
#
|
|
16
|
+
# __NOTE:__ It's suggested that your program <tt>require 'rdoc'</tt>,
|
|
17
|
+
# <tt>require 'rdoc/markup'</tt>, and <tt>require 'rdoc/markup/to_html'</tt> at load time
|
|
18
|
+
# when using this template engine in a threaded environment.
|
|
19
|
+
#
|
|
20
|
+
# === See also
|
|
21
|
+
#
|
|
22
|
+
# * {RDoc}[http://rdoc.rubyforge.org]
|
|
23
|
+
# * {RDoc Github}[https://github.com/ruby/rdoc]
|
|
24
|
+
|
|
2
25
|
require_relative 'template'
|
|
3
26
|
require 'rdoc'
|
|
4
27
|
require 'rdoc/markup'
|
|
5
28
|
require 'rdoc/markup/to_html'
|
|
6
29
|
require 'rdoc/options'
|
|
7
30
|
|
|
8
|
-
# RDoc template. See: https://github.com/ruby/rdoc
|
|
9
31
|
Tilt::RDocTemplate = Tilt::StaticTemplate.subclass do
|
|
10
32
|
RDoc::Markup::ToHtml.new(RDoc::Options.new, nil).convert(@data).to_s
|
|
11
33
|
end
|
data/lib/tilt/redcarpet.rb
CHANGED
|
@@ -1,4 +1,46 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Markdown (<tt>markdown</tt>, <tt>md</tt>, <tt>mkd</tt>)
|
|
4
|
+
#
|
|
5
|
+
# {Markdown}[http://daringfireball.net/projects/markdown/syntax] is a
|
|
6
|
+
# lightweight markup language, created by John Gruber and Aaron Swartz.
|
|
7
|
+
# For any markup that is not covered by Markdown’s syntax, HTML is used.
|
|
8
|
+
# Marking up plain text with Markdown markup is easy and Markdown
|
|
9
|
+
# formatted texts are readable.
|
|
10
|
+
#
|
|
11
|
+
# === Example
|
|
12
|
+
#
|
|
13
|
+
# Hello Markdown Templates
|
|
14
|
+
# ========================
|
|
15
|
+
#
|
|
16
|
+
# Hello World. This is a paragraph.
|
|
17
|
+
#
|
|
18
|
+
# === Usage
|
|
19
|
+
#
|
|
20
|
+
# To wrap a Markdown formatted document with a layout:
|
|
21
|
+
#
|
|
22
|
+
# layout = Tilt['erb'].new do
|
|
23
|
+
# "<!doctype html><title></title><%= yield %>"
|
|
24
|
+
# end
|
|
25
|
+
# data = Tilt['md'].new { "# hello tilt" }
|
|
26
|
+
# layout.render { data.render }
|
|
27
|
+
# # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
|
|
28
|
+
#
|
|
29
|
+
# === Options
|
|
30
|
+
#
|
|
31
|
+
# ==== <tt>:smartypants => true|false</tt>
|
|
32
|
+
#
|
|
33
|
+
# Set <tt>true</tt> to enable [Smarty Pants][smartypants] style punctuation replacement.
|
|
34
|
+
#
|
|
35
|
+
# ==== <tt>:escape_html => true|false</tt>
|
|
36
|
+
#
|
|
37
|
+
# Set <tt>true</tt> disallow raw HTML in Markdown contents. HTML is converted to
|
|
38
|
+
# literal text by escaping <tt><</tt> characters.
|
|
39
|
+
#
|
|
40
|
+
# === See also
|
|
41
|
+
#
|
|
42
|
+
# * {Markdown Syntax Documentation}[http://daringfireball.net/projects/markdown/syntax]
|
|
43
|
+
|
|
2
44
|
require_relative 'template'
|
|
3
45
|
require 'redcarpet'
|
|
4
46
|
|
data/lib/tilt/redcloth.rb
CHANGED
|
@@ -1,8 +1,35 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Textile (<tt>textile</tt>)
|
|
4
|
+
#
|
|
5
|
+
# Textile is a lightweight markup language originally developed by Dean Allen and
|
|
6
|
+
# billed as a "humane Web text generator". Textile converts its marked-up text
|
|
7
|
+
# input to valid, well-formed XHTML and also inserts character entity references
|
|
8
|
+
# for apostrophes, opening and closing single and double quotation marks,
|
|
9
|
+
# ellipses and em dashes.
|
|
10
|
+
#
|
|
11
|
+
# Textile formatted texts are converted to HTML with the {RedCloth}[http://redcloth.org]
|
|
12
|
+
# engine, which is a Ruby extension written in C.
|
|
13
|
+
#
|
|
14
|
+
# === Example
|
|
15
|
+
#
|
|
16
|
+
# h1. Hello Textile Templates
|
|
17
|
+
#
|
|
18
|
+
# Hello World. This is a paragraph.
|
|
19
|
+
#
|
|
20
|
+
# === Usage
|
|
21
|
+
#
|
|
22
|
+
# __NOTE:__ It's suggested that your program <tt>require 'redcloth'</tt> at load time
|
|
23
|
+
# when using this template engine in a threaded environment.
|
|
24
|
+
#
|
|
25
|
+
# === See Also
|
|
26
|
+
#
|
|
27
|
+
# * {RedCloth}[http://redcloth.org]
|
|
28
|
+
# * https://github.com/jgarber/redcloth
|
|
29
|
+
|
|
2
30
|
require_relative 'template'
|
|
3
31
|
require 'redcloth'
|
|
4
32
|
|
|
5
|
-
# RedCloth implementation. See: https://github.com/jgarber/redcloth
|
|
6
33
|
Tilt::RedClothTemplate = Tilt::StaticTemplate.subclass do
|
|
7
34
|
engine = RedCloth.new(@data)
|
|
8
35
|
@options.each do |k, v|
|
data/lib/tilt/rst-pandoc.rb
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = reStructuredText (<tt>rst</tt>)
|
|
4
|
+
#
|
|
5
|
+
# reStructuredText is a lightweight markup language originally developed by David Goodger,
|
|
6
|
+
# based on StructuredText and Setext. reStructuredText is primarily used for technical
|
|
7
|
+
# documentation in the Python programming language community, e.g. by the
|
|
8
|
+
# {Sphinx}[http://www.sphinx-doc.org/en/stable/rest.html] Python documentation generator.
|
|
9
|
+
#
|
|
10
|
+
# reStructuredText formatted texts are converted to HTML with {Pandoc}[http://pandoc.org/], which
|
|
11
|
+
# is an application written in Haskell, with a Ruby wrapper provided by the
|
|
12
|
+
# {pandoc-ruby}[https://github.com/alphabetum/pandoc-ruby] gem.
|
|
13
|
+
#
|
|
14
|
+
# === Example
|
|
15
|
+
#
|
|
16
|
+
# Hello Rst Templates
|
|
17
|
+
# ===================
|
|
18
|
+
#
|
|
19
|
+
# Hello World. This is a paragraph.
|
|
20
|
+
#
|
|
21
|
+
# === See Also
|
|
22
|
+
#
|
|
23
|
+
# * {Pandoc}[http://pandoc.org/]
|
|
24
|
+
# * {pandoc-ruby}[https://github.com/alphabetum/pandoc-ruby]
|
|
25
|
+
|
|
2
26
|
require_relative 'template'
|
|
3
27
|
require_relative 'pandoc'
|
|
4
28
|
|
|
5
29
|
rst = {:f => "rst"}.freeze
|
|
6
30
|
|
|
7
|
-
# Pandoc reStructuredText implementation. See: # http://pandoc.org/
|
|
8
31
|
Tilt::RstPandocTemplate = Tilt::StaticTemplate.subclass do
|
|
9
32
|
PandocRuby.new(@data, rst).to_html.strip
|
|
10
33
|
end
|
data/lib/tilt/sass.rb
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Sass / Scss
|
|
4
|
+
#
|
|
5
|
+
# Sass/Scss template implementation for generating CSS.
|
|
6
|
+
#
|
|
7
|
+
# Sass templates do not support object scopes, locals, or yield.
|
|
8
|
+
#
|
|
9
|
+
# === See also
|
|
10
|
+
#
|
|
11
|
+
# * https://sass-lang.com/
|
|
12
|
+
#
|
|
13
|
+
# === Related modules
|
|
14
|
+
#
|
|
15
|
+
# * Tilt::SassTemplate
|
|
16
|
+
# * Tilt::ScssTemplate
|
|
17
|
+
|
|
2
18
|
require_relative 'template'
|
|
3
19
|
|
|
4
20
|
module Tilt
|
|
5
|
-
# Sass template implementation for generating CSS. See: https://sass-lang.com/
|
|
6
|
-
#
|
|
7
|
-
# Sass templates do not support object scopes, locals, or yield.
|
|
8
21
|
class SassTemplate < StaticTemplate
|
|
9
22
|
self.default_mime_type = 'text/css'
|
|
10
23
|
|
data/lib/tilt/slim.rb
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Slim (<tt>slim</tt>)
|
|
4
|
+
#
|
|
5
|
+
# === Embedded locals
|
|
6
|
+
#
|
|
7
|
+
# In slim templates, the comment format looks like this:
|
|
8
|
+
#
|
|
9
|
+
# //# locals: ()
|
|
10
|
+
#
|
|
11
|
+
# === See also
|
|
12
|
+
#
|
|
13
|
+
# * https://slim-template.github.io
|
|
14
|
+
|
|
2
15
|
require_relative 'template'
|
|
3
16
|
require 'slim'
|
|
4
17
|
|
data/lib/tilt/string.rb
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = String
|
|
4
|
+
#
|
|
5
|
+
# The template source is evaluated as a Ruby string. The #{} interpolation
|
|
6
|
+
# syntax can be used to generated dynamic output.
|
|
7
|
+
#
|
|
8
|
+
# === Related module
|
|
9
|
+
#
|
|
10
|
+
# * Tilt::StringTemplate
|
|
11
|
+
|
|
2
12
|
require_relative 'template'
|
|
3
13
|
|
|
4
14
|
module Tilt
|
|
5
|
-
# The template source is evaluated as a Ruby string. The #{} interpolation
|
|
6
|
-
# syntax can be used to generated dynamic output.
|
|
7
15
|
class StringTemplate < Template
|
|
8
16
|
def prepare
|
|
9
17
|
hash = "TILT#{@data.hash.abs}"
|
data/lib/tilt/template.rb
CHANGED
|
@@ -41,12 +41,12 @@ module Tilt
|
|
|
41
41
|
@metadata ||= {}
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
# Use
|
|
44
|
+
# Use <tt>.metadata[:mime_type]</tt> instead.
|
|
45
45
|
def default_mime_type
|
|
46
46
|
metadata[:mime_type]
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
# Use
|
|
49
|
+
# Use <tt>.metadata[:mime_type] = val</tt> instead.
|
|
50
50
|
def default_mime_type=(value)
|
|
51
51
|
metadata[:mime_type] = value
|
|
52
52
|
end
|
|
@@ -376,10 +376,10 @@ module Tilt
|
|
|
376
376
|
|
|
377
377
|
s = "locals = locals[:locals]"
|
|
378
378
|
if assignments.delete(s)
|
|
379
|
-
# If there is a locals key itself named
|
|
379
|
+
# If there is a locals key itself named <tt>locals</tt>, delete it from the ordered keys so we can
|
|
380
380
|
# assign it last. This is important because the assignment of all other locals depends on the
|
|
381
|
-
#
|
|
382
|
-
# created in
|
|
381
|
+
# <tt>locals</tt> local variable still matching the <tt>locals</tt> method argument given to the method
|
|
382
|
+
# created in <tt>#compile_template_method</tt>.
|
|
383
383
|
assignments << s
|
|
384
384
|
end
|
|
385
385
|
|
data/lib/tilt/typescript.rb
CHANGED
data/lib/tilt/yajl.rb
CHANGED
|
@@ -1,44 +1,54 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Yajl
|
|
4
|
+
#
|
|
5
|
+
# Yajl Template implementation
|
|
6
|
+
#
|
|
7
|
+
# Yajl is a fast JSON parsing and encoding library for Ruby
|
|
8
|
+
#
|
|
9
|
+
# The template source is evaluated as a Ruby string,
|
|
10
|
+
# and the result is converted #to_json.
|
|
11
|
+
#
|
|
12
|
+
# === Example
|
|
13
|
+
#
|
|
14
|
+
# # This is a template example.
|
|
15
|
+
# # The template can contain any Ruby statement.
|
|
16
|
+
# tpl <<-EOS
|
|
17
|
+
# @counter = 0
|
|
18
|
+
#
|
|
19
|
+
# # The json variable represents the buffer
|
|
20
|
+
# # and holds the data to be serialized into json.
|
|
21
|
+
# # It defaults to an empty hash, but you can override it at any time.
|
|
22
|
+
# json = {
|
|
23
|
+
# :"user#{@counter += 1}" => { :name => "Joshua Peek", :id => @counter },
|
|
24
|
+
# :"user#{@counter += 1}" => { :name => "Ryan Tomayko", :id => @counter },
|
|
25
|
+
# :"user#{@counter += 1}" => { :name => "Simone Carletti", :id => @counter },
|
|
26
|
+
# }
|
|
27
|
+
#
|
|
28
|
+
# # Since the json variable is a Hash,
|
|
29
|
+
# # you can use conditional statements or any other Ruby statement
|
|
30
|
+
# # to populate it.
|
|
31
|
+
# json[:"user#{@counter += 1}"] = { :name => "Unknown" } if 1 == 2
|
|
32
|
+
#
|
|
33
|
+
# # The last line doesn't affect the returned value.
|
|
34
|
+
# nil
|
|
35
|
+
# EOS
|
|
36
|
+
#
|
|
37
|
+
# template = Tilt::YajlTemplate.new { tpl }
|
|
38
|
+
# template.render(self)
|
|
39
|
+
#
|
|
40
|
+
# === See also
|
|
41
|
+
#
|
|
42
|
+
# * https://github.com/brianmario/yajl-ruby
|
|
43
|
+
#
|
|
44
|
+
# === Related module
|
|
45
|
+
#
|
|
46
|
+
# * Tilt::YajlTemplate
|
|
47
|
+
|
|
2
48
|
require_relative 'template'
|
|
3
49
|
require 'yajl'
|
|
4
50
|
|
|
5
51
|
module Tilt
|
|
6
|
-
# Yajl Template implementation
|
|
7
|
-
#
|
|
8
|
-
# Yajl is a fast JSON parsing and encoding library for Ruby
|
|
9
|
-
# See https://github.com/brianmario/yajl-ruby
|
|
10
|
-
#
|
|
11
|
-
# The template source is evaluated as a Ruby string,
|
|
12
|
-
# and the result is converted #to_json.
|
|
13
|
-
#
|
|
14
|
-
# == Example
|
|
15
|
-
#
|
|
16
|
-
# # This is a template example.
|
|
17
|
-
# # The template can contain any Ruby statement.
|
|
18
|
-
# tpl <<-EOS
|
|
19
|
-
# @counter = 0
|
|
20
|
-
#
|
|
21
|
-
# # The json variable represents the buffer
|
|
22
|
-
# # and holds the data to be serialized into json.
|
|
23
|
-
# # It defaults to an empty hash, but you can override it at any time.
|
|
24
|
-
# json = {
|
|
25
|
-
# :"user#{@counter += 1}" => { :name => "Joshua Peek", :id => @counter },
|
|
26
|
-
# :"user#{@counter += 1}" => { :name => "Ryan Tomayko", :id => @counter },
|
|
27
|
-
# :"user#{@counter += 1}" => { :name => "Simone Carletti", :id => @counter },
|
|
28
|
-
# }
|
|
29
|
-
#
|
|
30
|
-
# # Since the json variable is a Hash,
|
|
31
|
-
# # you can use conditional statements or any other Ruby statement
|
|
32
|
-
# # to populate it.
|
|
33
|
-
# json[:"user#{@counter += 1}"] = { :name => "Unknown" } if 1 == 2
|
|
34
|
-
#
|
|
35
|
-
# # The last line doesn't affect the returned value.
|
|
36
|
-
# nil
|
|
37
|
-
# EOS
|
|
38
|
-
#
|
|
39
|
-
# template = Tilt::YajlTemplate.new { tpl }
|
|
40
|
-
# template.render(self)
|
|
41
|
-
#
|
|
42
52
|
class YajlTemplate < Template
|
|
43
53
|
self.default_mime_type = 'application/json'
|
|
44
54
|
|
data/lib/tilt.rb
CHANGED
|
@@ -5,7 +5,7 @@ require_relative 'tilt/template'
|
|
|
5
5
|
# Namespace for Tilt. This module is not intended to be included anywhere.
|
|
6
6
|
module Tilt
|
|
7
7
|
# Current version.
|
|
8
|
-
VERSION = '2.
|
|
8
|
+
VERSION = '2.7.0'
|
|
9
9
|
|
|
10
10
|
EMPTY_ARRAY = [].freeze
|
|
11
11
|
private_constant :EMPTY_ARRAY
|
|
@@ -163,7 +163,6 @@ module Tilt
|
|
|
163
163
|
register_lazy :CSVTemplate, 'tilt/csv', 'rcsv'
|
|
164
164
|
register_lazy :CoffeeScriptTemplate, 'tilt/coffee', 'coffee'
|
|
165
165
|
register_lazy :CoffeeScriptLiterateTemplate, 'tilt/coffee', 'litcoffee'
|
|
166
|
-
register_lazy :CreoleTemplate, 'tilt/creole', 'wiki', 'creole'
|
|
167
166
|
register_lazy :EtanniTemplate, 'tilt/etanni', 'etn', 'etanni'
|
|
168
167
|
register_lazy :HamlTemplate, 'tilt/haml', 'haml'
|
|
169
168
|
register_lazy :LiquidTemplate, 'tilt/liquid', 'liquid'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tilt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Tomayko
|
|
@@ -31,7 +31,6 @@ files:
|
|
|
31
31
|
- lib/tilt/cli.rb
|
|
32
32
|
- lib/tilt/coffee.rb
|
|
33
33
|
- lib/tilt/commonmarker.rb
|
|
34
|
-
- lib/tilt/creole.rb
|
|
35
34
|
- lib/tilt/csv.rb
|
|
36
35
|
- lib/tilt/erb.rb
|
|
37
36
|
- lib/tilt/erubi.rb
|
|
@@ -67,6 +66,7 @@ metadata:
|
|
|
67
66
|
changelog_uri: https://github.com/jeremyevans/tilt/blob/master/CHANGELOG.md
|
|
68
67
|
mailing_list_uri: https://github.com/jeremyevans/tilt/discussions
|
|
69
68
|
source_code_uri: https://github.com/jeremyevans/tilt
|
|
69
|
+
documentation_uri: https://tilt.jeremyevans.net
|
|
70
70
|
rdoc_options:
|
|
71
71
|
- "--line-numbers"
|
|
72
72
|
- "--inline-source"
|
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
88
|
version: '0'
|
|
89
89
|
requirements: []
|
|
90
|
-
rubygems_version:
|
|
90
|
+
rubygems_version: 4.0.3
|
|
91
91
|
specification_version: 4
|
|
92
92
|
summary: Generic interface to multiple Ruby template engines
|
|
93
93
|
test_files: []
|