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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4277574fbcafae6077fd4e64a6528e3117cae4aa653a471ab9179942a1440a3a
|
|
4
|
+
data.tar.gz: 0ebc6d611b50d8ef82eb91b6b09a5184788909716c4f6961dac770537b02aae6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c1b60402b38beff691e96630126af11e12a596df74923718e5ef99e66b2961218456d2dc0e7b87af1d2256603cee8cc0dba6823c8e39613fd790ebe39bd9b58
|
|
7
|
+
data.tar.gz: a55b63755285f279625ccc296fd637e22f3931c46549712ec8105c312e2bf537fac38882492691d6c1ad788f76e418ded62cbd6e6b2e54e3f3819cfc2f61b045
|
data/COPYING
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Copyright (c) 2010-2016 Ryan Tomayko <http://tomayko.com/about>
|
|
2
|
-
Copyright (c) 2015-
|
|
2
|
+
Copyright (c) 2015-2026 Jeremy Evans and contributors
|
|
3
3
|
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
5
|
of this software and associated documentation files (the "Software"), to
|
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
|
|
|
@@ -9,14 +50,24 @@ if defined?(::Commonmarker)
|
|
|
9
50
|
parse_opts = [
|
|
10
51
|
:smart,
|
|
11
52
|
:default_info_string,
|
|
53
|
+
:relaxed_tasklist_matching,
|
|
54
|
+
:relaxed_autolinks,
|
|
55
|
+
:leave_footnote_definitions,
|
|
56
|
+
:ignore_setext,
|
|
12
57
|
].freeze
|
|
13
58
|
render_opts = [
|
|
14
59
|
:hardbreaks,
|
|
15
60
|
:github_pre_lang,
|
|
61
|
+
:full_info_string,
|
|
16
62
|
:width,
|
|
17
63
|
:unsafe,
|
|
18
64
|
:escape,
|
|
19
65
|
:sourcepos,
|
|
66
|
+
:escaped_char_spans,
|
|
67
|
+
:ignore_empty_links,
|
|
68
|
+
:gfm_quirks,
|
|
69
|
+
:prefer_fenced,
|
|
70
|
+
:tasklist_classes,
|
|
20
71
|
].freeze
|
|
21
72
|
exts = [
|
|
22
73
|
:strikethrough,
|
|
@@ -27,9 +78,23 @@ if defined?(::Commonmarker)
|
|
|
27
78
|
:superscript,
|
|
28
79
|
:header_ids,
|
|
29
80
|
:footnotes,
|
|
81
|
+
:inline_footnotes,
|
|
30
82
|
:description_lists,
|
|
31
83
|
:front_matter_delimiter,
|
|
84
|
+
:multiline_block_quotes,
|
|
85
|
+
:math_dollars,
|
|
86
|
+
:math_code,
|
|
32
87
|
:shortcodes,
|
|
88
|
+
:wikilinks_title_before_pipe,
|
|
89
|
+
:wikilinks_title_after_pipe,
|
|
90
|
+
:underline,
|
|
91
|
+
:spoiler,
|
|
92
|
+
:greentext,
|
|
93
|
+
:subscript,
|
|
94
|
+
:subtext,
|
|
95
|
+
:alerts,
|
|
96
|
+
:cjk_friendly_emphasis,
|
|
97
|
+
:highlight,
|
|
33
98
|
].freeze
|
|
34
99
|
|
|
35
100
|
Tilt::CommonMarkerTemplate = Tilt::StaticTemplate.subclass do
|
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
|