tilt 2.6.1 → 2.8.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/COPYING +1 -1
- 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 +65 -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 +33 -3
- 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/mapping.rb
CHANGED
|
@@ -119,8 +119,8 @@ module Tilt
|
|
|
119
119
|
# # => RDiscount::Template
|
|
120
120
|
#
|
|
121
121
|
# In the previous example we say that RDiscount has a *higher priority* than
|
|
122
|
-
# Kramdown. Tilt will first try to
|
|
123
|
-
# back to
|
|
122
|
+
# Kramdown. Tilt will first try to <tt>require "rdiscount/template"</tt>, falling
|
|
123
|
+
# back to <tt>require "kramdown/template"</tt>. If none of these are successful,
|
|
124
124
|
# the first error will be raised.
|
|
125
125
|
class Mapping < BaseMapping
|
|
126
126
|
LOCK = Mutex.new
|
|
@@ -237,7 +237,7 @@ module Tilt
|
|
|
237
237
|
# :templates=>['erb', 'scss'])
|
|
238
238
|
def register_pipeline(ext, options=EMPTY_HASH)
|
|
239
239
|
templates = options[:templates] || ext.split('.').reverse
|
|
240
|
-
templates = templates.map{|t| [self[t], options[t] || EMPTY_HASH]}
|
|
240
|
+
templates = templates.map{|t| [self[t], t, options[t] || EMPTY_HASH]}
|
|
241
241
|
|
|
242
242
|
klass = Class.new(Pipeline)
|
|
243
243
|
klass.send(:const_set, :TEMPLATES, templates)
|
|
@@ -346,13 +346,13 @@ module Tilt
|
|
|
346
346
|
end
|
|
347
347
|
|
|
348
348
|
# The proper behavior (in MRI) for autoload? is to
|
|
349
|
-
# return
|
|
349
|
+
# return <tt>false</tt> when the constant/file has been
|
|
350
350
|
# explicitly required.
|
|
351
351
|
#
|
|
352
|
-
# However, in JRuby it returns
|
|
353
|
-
# been required. In that case it turns out that
|
|
354
|
-
# returns
|
|
355
|
-
# This is actually a second bug:
|
|
352
|
+
# However, in JRuby it returns <tt>true</tt> even after it's
|
|
353
|
+
# been required. In that case it turns out that <tt>defined?</tt>
|
|
354
|
+
# returns <tt>"constant"</tt> if it exists and <tt>nil</tt> when it doesn't.
|
|
355
|
+
# This is actually a second bug: <tt>defined?</tt> should resolve
|
|
356
356
|
# autoload (aka. actually try to require the file).
|
|
357
357
|
#
|
|
358
358
|
# We use the second bug in order to resolve the first bug.
|
data/lib/tilt/markaby.rb
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Markaby
|
|
4
|
+
#
|
|
5
|
+
# === See also
|
|
6
|
+
#
|
|
7
|
+
# * http://github.com/markaby/markaby
|
|
8
|
+
#
|
|
9
|
+
# === Related module
|
|
10
|
+
#
|
|
11
|
+
# * Tilt::MarkabyTemplate
|
|
12
|
+
|
|
2
13
|
require_relative 'template'
|
|
3
14
|
require 'markaby'
|
|
4
15
|
|
|
5
16
|
module Tilt
|
|
6
|
-
# Markaby
|
|
7
|
-
# http://github.com/markaby/markaby
|
|
8
17
|
class MarkabyTemplate < Template
|
|
9
18
|
def self.builder_class
|
|
10
19
|
@builder_class ||= Class.new(Markaby::Builder) do
|
data/lib/tilt/nokogiri.rb
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Nokogiri
|
|
4
|
+
#
|
|
5
|
+
# Nokogiri template implementation.
|
|
6
|
+
#
|
|
7
|
+
# === See also
|
|
8
|
+
#
|
|
9
|
+
# * http://nokogiri.org/
|
|
10
|
+
#
|
|
11
|
+
# === Related module
|
|
12
|
+
#
|
|
13
|
+
# * Tilt::NokogiriTemplate
|
|
14
|
+
|
|
2
15
|
require_relative 'template'
|
|
3
16
|
require 'nokogiri'
|
|
4
17
|
|
|
5
18
|
module Tilt
|
|
6
|
-
# Nokogiri template implementation. See:
|
|
7
|
-
# http://nokogiri.org/
|
|
8
19
|
class NokogiriTemplate < Template
|
|
9
20
|
DOCUMENT_HEADER = /\A<\?xml version=\"1\.0\"\?>\n?/
|
|
10
21
|
self.default_mime_type = 'text/xml'
|
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,41 @@
|
|
|
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
|
-
|
|
9
|
-
Tilt::
|
|
10
|
-
|
|
31
|
+
Tilt::RDocTemplate = if defined?(RDoc::VERSION) && RDoc::VERSION >= "8"
|
|
32
|
+
Tilt::StaticTemplate.subclass do
|
|
33
|
+
RDoc::Markup::ToHtml.new.convert(@data).to_s
|
|
34
|
+
end
|
|
35
|
+
# :nocov:
|
|
36
|
+
else
|
|
37
|
+
Tilt::StaticTemplate.subclass do
|
|
38
|
+
RDoc::Markup::ToHtml.new(RDoc::Options.new, nil).convert(@data).to_s
|
|
39
|
+
end
|
|
11
40
|
end
|
|
41
|
+
# :nocov:
|
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
|
|