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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e425f100107f57bdcf754dde8fcabc9a1d63ad9ee1ad5e2bffe2b5103affc712
|
|
4
|
+
data.tar.gz: 655f9f6617846da59ce0011c4ad15cb20ec01b55045662a4ef6d4537b6ff523c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18339cfc7b770f714aa272fa5bc8d9d0726b23b0cff8df69c45f2bafa3a341705c50c152bff1c20187b328e46c05b08a0e7a2ab0339352e42afd871559fecf8b
|
|
7
|
+
data.tar.gz: c0d5aee0ec0c2cab1f30aef4bc783432ce945dd446c929b3af370f2f57175718d76ae5f55e0ba1df29de2dc64720d4c911592c9ea0516b8e6abfd06daef656c7
|
data/lib/tilt/asciidoc.rb
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
require_relative 'template'
|
|
3
|
-
require 'asciidoctor'
|
|
4
|
-
# AsciiDoc see: http://asciidoc.org/
|
|
5
2
|
|
|
6
|
-
#
|
|
7
|
-
#
|
|
3
|
+
# = AsciiDoc
|
|
4
|
+
#
|
|
5
|
+
# Asciidoctor implementation for AsciiDoc
|
|
8
6
|
#
|
|
9
7
|
# Asciidoctor is an open source, pure-Ruby processor for
|
|
10
8
|
# converting AsciiDoc documents or strings into HTML 5,
|
|
11
9
|
# DocBook 4.5 and other formats.
|
|
10
|
+
#
|
|
11
|
+
# === See also
|
|
12
|
+
#
|
|
13
|
+
# * http://asciidoc.org
|
|
14
|
+
# * http://asciidoctor.github.com
|
|
15
|
+
|
|
16
|
+
require_relative 'template'
|
|
17
|
+
require 'asciidoctor'
|
|
18
|
+
|
|
12
19
|
Tilt::AsciidoctorTemplate = Tilt::StaticTemplate.subclass do
|
|
13
20
|
@options[:header_footer] = false if @options[:header_footer].nil?
|
|
14
21
|
Asciidoctor.render(@data, @options)
|
data/lib/tilt/babel.rb
CHANGED
data/lib/tilt/builder.rb
CHANGED
data/lib/tilt/coffee.rb
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# CoffeeScript / Literate CoffeeScript template implementation.
|
|
4
|
+
#
|
|
5
|
+
# CoffeeScript templates do not support object scopes, locals, or yield.
|
|
6
|
+
#
|
|
7
|
+
# === See also
|
|
8
|
+
#
|
|
9
|
+
# * http://coffeescript.org
|
|
10
|
+
#
|
|
11
|
+
# === Related modules
|
|
12
|
+
#
|
|
13
|
+
# * Tilt::CoffeeScriptTemplate
|
|
14
|
+
# * Tilt::CoffeeScriptLiterateTemplate
|
|
15
|
+
|
|
2
16
|
require_relative 'template'
|
|
3
17
|
require 'coffee_script'
|
|
4
18
|
|
|
5
19
|
module Tilt
|
|
6
|
-
# CoffeeScript template implementation. See:
|
|
7
|
-
# http://coffeescript.org/
|
|
8
|
-
#
|
|
9
|
-
# CoffeeScript templates do not support object scopes, locals, or yield.
|
|
10
20
|
class CoffeeScriptTemplate < StaticTemplate
|
|
11
21
|
self.default_mime_type = 'application/javascript'
|
|
12
22
|
|
data/lib/tilt/commonmarker.rb
CHANGED
|
@@ -1,4 +1,45 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# = Markdown (<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
|
+
# === Example
|
|
11
|
+
#
|
|
12
|
+
# Hello Markdown Templates
|
|
13
|
+
# ========================
|
|
14
|
+
#
|
|
15
|
+
# Hello World. This is a paragraph.
|
|
16
|
+
#
|
|
17
|
+
# === Usage
|
|
18
|
+
#
|
|
19
|
+
# To wrap a Markdown formatted document with a layout:
|
|
20
|
+
#
|
|
21
|
+
# layout = Tilt['erb'].new do
|
|
22
|
+
# "<!doctype html><title></title><%= yield %>"
|
|
23
|
+
# end
|
|
24
|
+
# data = Tilt['md'].new { "# hello tilt" }
|
|
25
|
+
# layout.render { data.render }
|
|
26
|
+
# # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
|
|
27
|
+
#
|
|
28
|
+
# === Options
|
|
29
|
+
#
|
|
30
|
+
# ==== <tt>:smartypants => true|false</tt>
|
|
31
|
+
#
|
|
32
|
+
# Set <tt>true</tt> to enable [Smarty Pants][smartypants] style punctuation replacement.
|
|
33
|
+
#
|
|
34
|
+
# ==== <tt>:escape_html => true|false</tt>
|
|
35
|
+
#
|
|
36
|
+
# Set <tt>true</tt> disallow raw HTML in Markdown contents. HTML is converted to
|
|
37
|
+
# literal text by escaping <tt><</tt> characters.
|
|
38
|
+
#
|
|
39
|
+
# === See also
|
|
40
|
+
#
|
|
41
|
+
# * {Markdown Syntax Documentation}[http://daringfireball.net/projects/markdown/syntax]
|
|
42
|
+
|
|
2
43
|
require_relative 'template'
|
|
3
44
|
require 'commonmarker'
|
|
4
45
|
|
data/lib/tilt/csv.rb
CHANGED
|
@@ -1,34 +1,44 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = CSV
|
|
4
|
+
#
|
|
5
|
+
# CSV Template implementation.
|
|
6
|
+
#
|
|
7
|
+
# === Example
|
|
8
|
+
#
|
|
9
|
+
# # Example of csv template
|
|
10
|
+
# tpl = <<-EOS
|
|
11
|
+
# # header
|
|
12
|
+
# csv << ['NAME', 'ID']
|
|
13
|
+
#
|
|
14
|
+
# # data rows
|
|
15
|
+
# @people.each do |person|
|
|
16
|
+
# csv << [person[:name], person[:id]]
|
|
17
|
+
# end
|
|
18
|
+
# EOS
|
|
19
|
+
#
|
|
20
|
+
# @people = [
|
|
21
|
+
# {:name => "Joshua Peek", :id => 1},
|
|
22
|
+
# {:name => "Ryan Tomayko", :id => 2},
|
|
23
|
+
# {:name => "Simone Carletti", :id => 3}
|
|
24
|
+
# ]
|
|
25
|
+
#
|
|
26
|
+
# template = Tilt::CSVTemplate.new { tpl }
|
|
27
|
+
# template.render(self)
|
|
28
|
+
#
|
|
29
|
+
# === See also
|
|
30
|
+
#
|
|
31
|
+
# * http://ruby-doc.org/stdlib/libdoc/csv/rdoc/CSV.html
|
|
32
|
+
#
|
|
33
|
+
# === Related module
|
|
34
|
+
#
|
|
35
|
+
# * Tilt::CSVTemplate
|
|
36
|
+
|
|
2
37
|
require_relative 'template'
|
|
3
38
|
require 'csv'
|
|
4
39
|
|
|
5
40
|
module Tilt
|
|
6
41
|
|
|
7
|
-
# CSV Template implementation. See:
|
|
8
|
-
# http://ruby-doc.org/stdlib/libdoc/csv/rdoc/CSV.html
|
|
9
|
-
#
|
|
10
|
-
# == Example
|
|
11
|
-
#
|
|
12
|
-
# # Example of csv template
|
|
13
|
-
# tpl = <<-EOS
|
|
14
|
-
# # header
|
|
15
|
-
# csv << ['NAME', 'ID']
|
|
16
|
-
#
|
|
17
|
-
# # data rows
|
|
18
|
-
# @people.each do |person|
|
|
19
|
-
# csv << [person[:name], person[:id]]
|
|
20
|
-
# end
|
|
21
|
-
# EOS
|
|
22
|
-
#
|
|
23
|
-
# @people = [
|
|
24
|
-
# {:name => "Joshua Peek", :id => 1},
|
|
25
|
-
# {:name => "Ryan Tomayko", :id => 2},
|
|
26
|
-
# {:name => "Simone Carletti", :id => 3}
|
|
27
|
-
# ]
|
|
28
|
-
#
|
|
29
|
-
# template = Tilt::CSVTemplate.new { tpl }
|
|
30
|
-
# template.render(self)
|
|
31
|
-
#
|
|
32
42
|
class CSVTemplate < Template
|
|
33
43
|
self.default_mime_type = 'text/csv'
|
|
34
44
|
|
data/lib/tilt/erb.rb
CHANGED
|
@@ -1,10 +1,75 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = ERB (<tt>erb</tt>, <tt>rhtml</tt>)
|
|
4
|
+
#
|
|
5
|
+
# ERB is a simple but powerful template languge for Ruby. In Tilt it's
|
|
6
|
+
# backed by {Erubi}[rdoc-ref:lib/tilt/erubi.rb] (if installed on your system] or by
|
|
7
|
+
# {erb.rb}[rdoc-ref:lib/tilt/erb.rb] (which is included in Ruby's standard library]. This
|
|
8
|
+
# documentation applies to both implementations.
|
|
9
|
+
#
|
|
10
|
+
# === Example
|
|
11
|
+
#
|
|
12
|
+
# Hello <%= world %>!
|
|
13
|
+
#
|
|
14
|
+
# === Usage
|
|
15
|
+
#
|
|
16
|
+
# ERB templates support custom evaluation scopes and locals:
|
|
17
|
+
#
|
|
18
|
+
# >> require 'erb'
|
|
19
|
+
# >> template = Tilt.new('hello.html.erb')
|
|
20
|
+
# >> template.render(self, :world => 'World!')
|
|
21
|
+
# => "Hello World!"
|
|
22
|
+
#
|
|
23
|
+
# Or, use <tt>Tilt['erb']</tt> directly to process strings:
|
|
24
|
+
#
|
|
25
|
+
# template = Tilt['erb'].new { "Hello <%= world %>!" }
|
|
26
|
+
# template.render(self, :world => 'World!')
|
|
27
|
+
#
|
|
28
|
+
# The <tt>Tilt::ERBTemplate</tt> class is registered for all files ending in <tt>.erb</tt> or
|
|
29
|
+
# <tt>.rhtml</tt> by default, but with a *lower* priority than ErubiTemplate.
|
|
30
|
+
# If you specifically want to use ERB, it's recommended to use
|
|
31
|
+
# <tt>#prefer</tt>:
|
|
32
|
+
#
|
|
33
|
+
# Tilt.prefer Tilt::ERBTemplate
|
|
34
|
+
#
|
|
35
|
+
# __NOTE:__ It's suggested that your program <tt>require 'erb'</tt> at load time when
|
|
36
|
+
# using this template engine within a threaded environment.
|
|
37
|
+
#
|
|
38
|
+
# === Options
|
|
39
|
+
#
|
|
40
|
+
# ==== <tt>:trim => trim</tt>
|
|
41
|
+
#
|
|
42
|
+
# The ERB trim mode flags. This is a string consisting of any combination of the
|
|
43
|
+
# following characters:
|
|
44
|
+
#
|
|
45
|
+
# * <tt>'>'</tt> omits newlines for lines ending in <tt>></tt>
|
|
46
|
+
# * <tt>'<>'</tt> omits newlines for lines starting with <tt><%</tt> and ending in <tt>%></tt>
|
|
47
|
+
# * <tt>'%'</tt> enables processing of lines beginning with <tt>%</tt>
|
|
48
|
+
# * <tt>true</tt> is an alias of <tt><></tt>
|
|
49
|
+
#
|
|
50
|
+
# ==== <tt>:outvar => '_erbout'</tt>
|
|
51
|
+
#
|
|
52
|
+
# The name of the variable used to accumulate template output. This can be
|
|
53
|
+
# any valid Ruby expression but must be assignable. By default a local
|
|
54
|
+
# variable named <tt>_erbout</tt> is used.
|
|
55
|
+
#
|
|
56
|
+
# ==== <tt>:freeze => false</tt>
|
|
57
|
+
#
|
|
58
|
+
# If set to true, will set the <tt>frozen_string_literal</tt> flag in the compiled
|
|
59
|
+
# template code, so that string literals inside the templates will be frozen.
|
|
60
|
+
#
|
|
61
|
+
# === See also
|
|
62
|
+
#
|
|
63
|
+
# * http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html
|
|
64
|
+
#
|
|
65
|
+
# === Related module
|
|
66
|
+
#
|
|
67
|
+
# * Tilt::ERBTemplate
|
|
68
|
+
|
|
2
69
|
require_relative 'template'
|
|
3
70
|
require 'erb'
|
|
4
71
|
|
|
5
72
|
module Tilt
|
|
6
|
-
# ERB template implementation. See:
|
|
7
|
-
# http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html
|
|
8
73
|
class ERBTemplate < Template
|
|
9
74
|
SUPPORTS_KVARGS = ::ERB.instance_method(:initialize).parameters.assoc(:key) rescue false
|
|
10
75
|
|
data/lib/tilt/erubi.rb
CHANGED
|
@@ -1,16 +1,49 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Erubi (<tt>erb</tt>, <tt>rhtml</tt>, <tt>erubi</tt>)
|
|
4
|
+
#
|
|
5
|
+
# {Erubi}[https://github.com/jeremyevans/erubi] is an ERB implementation that uses the same algorithm as
|
|
6
|
+
# the erubis gem, but is maintained and offers numerous improvements.
|
|
7
|
+
#
|
|
8
|
+
# All the documentation of {ERB}[rdoc-ref:lib/tilt/erb.rb] applies in addition to the following:
|
|
9
|
+
#
|
|
10
|
+
# === Usage
|
|
11
|
+
#
|
|
12
|
+
# The <tt>Tilt::ErubiTemplate</tt> class is registered for all files ending in <tt>.erb</tt> or
|
|
13
|
+
# <tt>.rhtml</tt> by default, with the *highest* priority.
|
|
14
|
+
#
|
|
15
|
+
# __NOTE:__ It's suggested that your program <tt>require 'erubi'</tt> at load time when
|
|
16
|
+
# using this template engine within a threaded environment.
|
|
17
|
+
#
|
|
18
|
+
# === Options
|
|
19
|
+
#
|
|
20
|
+
# ==== <tt>:engine_class => Erubi::Engine</tt>
|
|
21
|
+
#
|
|
22
|
+
# Allows you to specify a custom engine class to use instead of the
|
|
23
|
+
# default which is <tt>Erubi::Engine</tt>.
|
|
24
|
+
#
|
|
25
|
+
# ==== Other
|
|
26
|
+
#
|
|
27
|
+
# Other options are passed to the constructor of the engine class.
|
|
28
|
+
#
|
|
29
|
+
# ErubiTemplate supports the following additional options, in addition
|
|
30
|
+
# to the options supported by the Erubi engine:
|
|
31
|
+
#
|
|
32
|
+
# :engine_class :: allows you to specify a custom engine class to use
|
|
33
|
+
# instead of the default (which is ::Erubi::Engine).
|
|
34
|
+
#
|
|
35
|
+
# === See also
|
|
36
|
+
#
|
|
37
|
+
# * {Erubi Home}[https://github.com/jeremyevans/erubi]
|
|
38
|
+
#
|
|
39
|
+
# === Related module
|
|
40
|
+
#
|
|
41
|
+
# * Tilt::ErubiTemplate
|
|
42
|
+
|
|
2
43
|
require_relative 'template'
|
|
3
44
|
require 'erubi'
|
|
4
45
|
|
|
5
46
|
module Tilt
|
|
6
|
-
# Erubi (a simplified version of Erubis) template implementation.
|
|
7
|
-
# See https://github.com/jeremyevans/erubi
|
|
8
|
-
#
|
|
9
|
-
# ErubiTemplate supports the following additional options, in addition
|
|
10
|
-
# to the options supported by the Erubi engine:
|
|
11
|
-
#
|
|
12
|
-
# :engine_class :: allows you to specify a custom engine class to use
|
|
13
|
-
# instead of the default (which is ::Erubi::Engine).
|
|
14
47
|
class ErubiTemplate < Template
|
|
15
48
|
def prepare
|
|
16
49
|
@options[:preamble] = false
|
data/lib/tilt/etanni.rb
CHANGED
data/lib/tilt/haml.rb
CHANGED
|
@@ -1,4 +1,70 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Haml (<tt>haml</tt>)
|
|
4
|
+
#
|
|
5
|
+
# {Haml}[https://haml.info] is a markup language that’s used to cleanly and simply describe
|
|
6
|
+
# the HTML of any web document without the use of inline code. Haml functions as
|
|
7
|
+
# a replacement for inline page templating systems such as PHP, ASP, and ERB, the
|
|
8
|
+
# templating language used in most Ruby on Rails applications. However, Haml
|
|
9
|
+
# avoids the need for explicitly coding HTML into the template, because it itself
|
|
10
|
+
# is a description of the HTML, with some code to generate dynamic content.
|
|
11
|
+
# ({more}[http://haml.info/about.html)]
|
|
12
|
+
#
|
|
13
|
+
# === Example
|
|
14
|
+
#
|
|
15
|
+
# %html
|
|
16
|
+
# %head
|
|
17
|
+
# %title= @title
|
|
18
|
+
# %body
|
|
19
|
+
# %h1
|
|
20
|
+
# Hello
|
|
21
|
+
# = world + '!'
|
|
22
|
+
#
|
|
23
|
+
# === Usage
|
|
24
|
+
#
|
|
25
|
+
# The <tt>Tilt::HamlTemplate</tt> class is registered for all files ending in <tt>.haml</tt>
|
|
26
|
+
# by default. Haml templates support custom evaluation scopes and locals:
|
|
27
|
+
#
|
|
28
|
+
# >> require 'haml'
|
|
29
|
+
# >> template = Tilt.new('hello.haml')
|
|
30
|
+
# => #<Tilt::HamlTemplate @file='hello.haml'>
|
|
31
|
+
# >> @title = "Hello Haml!"
|
|
32
|
+
# >> template.render(self, :world => 'Haml!')
|
|
33
|
+
# => "
|
|
34
|
+
# <html>
|
|
35
|
+
# <head>
|
|
36
|
+
# <title>Hello Haml!</title>
|
|
37
|
+
# </head>
|
|
38
|
+
# <body>
|
|
39
|
+
# <h1>Hello Haml!</h1>
|
|
40
|
+
# </body>
|
|
41
|
+
# </html>"
|
|
42
|
+
#
|
|
43
|
+
# Or, use the <tt>Tilt::HamlTemplate</tt> class directly to process strings:
|
|
44
|
+
#
|
|
45
|
+
# >> require 'haml'
|
|
46
|
+
# >> template = Tilt::HamlTemplate.new { "%h1= 'Hello Haml!'" }
|
|
47
|
+
# => #<Tilt::HamlTemplate @file=nil ...>
|
|
48
|
+
# >> template.render
|
|
49
|
+
# => "<h1>Hello Haml!</h1>"
|
|
50
|
+
#
|
|
51
|
+
# __NOTE:__ It's suggested that your program <tt>require 'haml'</tt> at load time when
|
|
52
|
+
# using this template engine within a threaded environment.
|
|
53
|
+
#
|
|
54
|
+
# === Options
|
|
55
|
+
#
|
|
56
|
+
# Please see the {Haml Reference}[http://haml.info/docs/yardoc/file.HAML_REFERENCE.html#options] for all available options.
|
|
57
|
+
#
|
|
58
|
+
# === See also
|
|
59
|
+
#
|
|
60
|
+
# * {#haml.docs}[http://haml.info/docs.html]
|
|
61
|
+
# * {Haml Tutorial}[http://haml.info/tutorial.html]
|
|
62
|
+
# * {Haml Reference}[http://haml.info/docs/yardoc/file.HAML_REFERENCE.html]
|
|
63
|
+
#
|
|
64
|
+
# === Related module
|
|
65
|
+
#
|
|
66
|
+
# * Tilt::HamlTemplate
|
|
67
|
+
|
|
2
68
|
require_relative 'template'
|
|
3
69
|
require 'haml'
|
|
4
70
|
|
|
@@ -12,7 +78,7 @@ module Tilt
|
|
|
12
78
|
class HamlTemplate < Template
|
|
13
79
|
self.default_mime_type = 'text/html'
|
|
14
80
|
|
|
15
|
-
#
|
|
81
|
+
# <tt>Gem::Version.correct?</tt> may return false because of Haml::VERSION #=> "3.1.8 (Separated Sally)". After Haml 4, it's always correct.
|
|
16
82
|
if Gem::Version.correct?(Haml::VERSION) && Gem::Version.new(Haml::VERSION) >= Gem::Version.new('5.0.0.beta.2')
|
|
17
83
|
def prepare
|
|
18
84
|
@options[:filename] = eval_file
|
data/lib/tilt/kramdown.rb
CHANGED
|
@@ -1,10 +1,56 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Markdown (<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
|
+
# === Example
|
|
11
|
+
#
|
|
12
|
+
# Hello Markdown Templates
|
|
13
|
+
# ========================
|
|
14
|
+
#
|
|
15
|
+
# Hello World. This is a paragraph.
|
|
16
|
+
#
|
|
17
|
+
# === Usage
|
|
18
|
+
#
|
|
19
|
+
# To wrap a Markdown formatted document with a layout:
|
|
20
|
+
#
|
|
21
|
+
# layout = Tilt['erb'].new do
|
|
22
|
+
# "<!doctype html><title></title><%= yield %>"
|
|
23
|
+
# end
|
|
24
|
+
# data = Tilt['md'].new { "# hello tilt" }
|
|
25
|
+
# layout.render { data.render }
|
|
26
|
+
# # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
|
|
27
|
+
#
|
|
28
|
+
# === Options
|
|
29
|
+
#
|
|
30
|
+
# Every implementation of Markdown *should* support these options, but there are
|
|
31
|
+
# some known problems with the Kramdown engine.
|
|
32
|
+
#
|
|
33
|
+
# ==== <tt>:smartypants => true|false</tt>
|
|
34
|
+
#
|
|
35
|
+
# Set <tt>true</tt> to enable [Smarty Pants][smartypants] style punctuation replacement.
|
|
36
|
+
#
|
|
37
|
+
# In Kramdown this option only applies to smart quotes. It will apply a
|
|
38
|
+
# subset of Smarty Pants (e.g. <tt>...</tt> to <tt>…</tt>) regardless of any option.
|
|
39
|
+
#
|
|
40
|
+
# ==== <tt>:escape_html => true|false</tt>
|
|
41
|
+
#
|
|
42
|
+
# Kramdown doesn't support this option.
|
|
43
|
+
#
|
|
44
|
+
# === See also
|
|
45
|
+
#
|
|
46
|
+
# * {Markdown Syntax Documentation}[http://daringfireball.net/projects/markdown/syntax]
|
|
47
|
+
# * {Kramdown Markdown implementation}[https://kramdown.gettalong.org]
|
|
48
|
+
|
|
2
49
|
require_relative 'template'
|
|
3
50
|
require 'kramdown'
|
|
4
51
|
|
|
5
52
|
dumb_quotes = [39, 39, 34, 34].freeze
|
|
6
53
|
|
|
7
|
-
# Kramdown Markdown implementation. See: https://kramdown.gettalong.org/
|
|
8
54
|
Tilt::KramdownTemplate = Tilt::StaticTemplate.subclass do
|
|
9
55
|
# dup as Krawmdown modifies the passed option with map!
|
|
10
56
|
@options[:smart_quotes] = dumb_quotes.dup unless @options[:smartypants]
|
data/lib/tilt/liquid.rb
CHANGED
|
@@ -1,18 +1,74 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# = Liquid (<tt>liquid</tt>)
|
|
4
|
+
#
|
|
5
|
+
# Liquid is designed to be a *safe* template system and therefore
|
|
6
|
+
# does not provide direct access to execuatable scopes. In order to
|
|
7
|
+
# support a +scope+, the +scope+ must be able to represent itself
|
|
8
|
+
# as a hash by responding to #to_h. If the +scope+ does not respond
|
|
9
|
+
# to #to_h it will be ignored.
|
|
10
|
+
#
|
|
11
|
+
# LiquidTemplate does not support yield blocks.
|
|
12
|
+
#
|
|
13
|
+
# === Example
|
|
14
|
+
#
|
|
15
|
+
# <html>
|
|
16
|
+
# <head>
|
|
17
|
+
# <title>{{ title }}</title>
|
|
18
|
+
# </head>
|
|
19
|
+
# <body>
|
|
20
|
+
# <h1>Hello {{ world }}!</h1>
|
|
21
|
+
# </body>
|
|
22
|
+
# </html>
|
|
23
|
+
#
|
|
24
|
+
# === Usage
|
|
25
|
+
#
|
|
26
|
+
# <tt>Tilt::LiquidTemplate</tt> is registered for all files ending in <tt>.liquid</tt> by
|
|
27
|
+
# default. Liquid templates support locals and objects that respond to
|
|
28
|
+
# <tt>#to_h</tt> as scopes:
|
|
29
|
+
#
|
|
30
|
+
# >> require 'liquid'
|
|
31
|
+
# >> require 'tilt'
|
|
32
|
+
# >> template = Tilt.new('hello.liquid')
|
|
33
|
+
# => #<Tilt::LiquidTemplate @file='hello.liquid'>
|
|
34
|
+
# >> scope = { :title => "Hello Liquid Templates" }
|
|
35
|
+
# >> template.render(nil, :world => "Liquid")
|
|
36
|
+
# => "
|
|
37
|
+
# <html>
|
|
38
|
+
# <head>
|
|
39
|
+
# <title>Hello Liquid Templates</title>
|
|
40
|
+
# </head>
|
|
41
|
+
# <body>
|
|
42
|
+
# <h1>Hello Liquid!</h1>
|
|
43
|
+
# </body>
|
|
44
|
+
# </html>"
|
|
45
|
+
#
|
|
46
|
+
# Or, use <tt>Tilt::LiquidTemplate</tt> directly to process strings:
|
|
47
|
+
#
|
|
48
|
+
# >> require 'liquid'
|
|
49
|
+
# >> template = Tilt::LiquidTemplate.new { "<h1>Hello Liquid!</h1>" }
|
|
50
|
+
# => #<Tilt::LiquidTemplate @file=nil ...>
|
|
51
|
+
# >> template.render
|
|
52
|
+
# => "<h1>Hello Liquid!</h1>"
|
|
53
|
+
#
|
|
54
|
+
# __NOTE:__ It's suggested that your program <tt>require 'liquid'</tt> at load
|
|
55
|
+
# time when using this template engine within a threaded environment.
|
|
56
|
+
#
|
|
57
|
+
# === See also
|
|
58
|
+
#
|
|
59
|
+
# * {Liquid}[http://liquidmarkup.org]
|
|
60
|
+
# * {Liquid for Programmers}[https://wiki.github.com/Shopify/liquid/liquid-for-programmers]
|
|
61
|
+
# * {Liquid Docs}[http://liquid.rubyforge.org/]
|
|
62
|
+
# * GitHub: {Shopify/liquid}[https://github.com/Shopify/liquid/]
|
|
63
|
+
#
|
|
64
|
+
# === Related module
|
|
65
|
+
#
|
|
66
|
+
# * Tilt::LiquidTemplate
|
|
67
|
+
|
|
2
68
|
require_relative 'template'
|
|
3
69
|
require 'liquid'
|
|
4
70
|
|
|
5
71
|
module Tilt
|
|
6
|
-
# Liquid template implementation. See:
|
|
7
|
-
# http://liquidmarkup.org/
|
|
8
|
-
#
|
|
9
|
-
# Liquid is designed to be a *safe* template system and therefore
|
|
10
|
-
# does not provide direct access to execuatable scopes. In order to
|
|
11
|
-
# support a +scope+, the +scope+ must be able to represent itself
|
|
12
|
-
# as a hash by responding to #to_h. If the +scope+ does not respond
|
|
13
|
-
# to #to_h it will be ignored.
|
|
14
|
-
#
|
|
15
|
-
# LiquidTemplate does not support yield blocks.
|
|
16
72
|
class LiquidTemplate < Template
|
|
17
73
|
def prepare
|
|
18
74
|
@options[:line_numbers] = true unless @options.has_key?(:line_numbers)
|
data/lib/tilt/livescript.rb
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
require_relative 'template'
|
|
3
|
-
require 'livescript'
|
|
4
2
|
|
|
5
|
-
# LiveScript
|
|
6
|
-
#
|
|
3
|
+
# = LiveScript
|
|
4
|
+
#
|
|
5
|
+
# LiveScript template implementation.
|
|
7
6
|
#
|
|
8
7
|
# LiveScript templates do not support object scopes, locals, or yield.
|
|
8
|
+
#
|
|
9
|
+
# === See also
|
|
10
|
+
#
|
|
11
|
+
# * http://livescript.net
|
|
12
|
+
|
|
13
|
+
require_relative 'template'
|
|
14
|
+
require 'livescript'
|
|
15
|
+
|
|
9
16
|
Tilt::LiveScriptTemplate = Tilt::StaticTemplate.subclass(mime_type: 'application/javascript') do
|
|
10
17
|
LiveScript.compile(@data, @options)
|
|
11
18
|
end
|
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'
|