pug-ruby 1.0.2 → 2.0.0.rc1
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/.gitignore +3 -1
- data/.rubocop.yml +81 -0
- data/.travis.yml +17 -8
- data/.yardopts +4 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +32 -0
- data/LICENSE +21 -0
- data/README.md +256 -24
- data/Rakefile +74 -8
- data/lib/jade-pug/base.rb +178 -0
- data/lib/jade-pug/compiler.rb +166 -0
- data/lib/jade-pug/config.rb +60 -0
- data/lib/jade-pug/errors/compilation-error.rb +14 -0
- data/lib/jade-pug/errors/compiler-error.rb +13 -0
- data/lib/jade-pug/shipped-compiler.rb +80 -0
- data/lib/jade-pug/system-compiler.rb +139 -0
- data/lib/jade-ruby/compilation-essentials.rb +24 -0
- data/lib/jade-ruby/config.rb +17 -44
- data/lib/jade-ruby/errors/compilation-error.rb +14 -0
- data/lib/jade-ruby/errors/compiler-error.rb +13 -0
- data/lib/jade-ruby/shipped-compiler.rb +15 -0
- data/lib/jade-ruby/system-compiler.rb +15 -0
- data/lib/pug-ruby.rb +46 -5
- data/lib/pug-ruby/compilation-essentials.rb +29 -0
- data/lib/pug-ruby/config.rb +11 -37
- data/lib/pug-ruby/errors/compilation-error.rb +14 -0
- data/lib/pug-ruby/errors/compiler-error.rb +13 -0
- data/lib/pug-ruby/shipped-compiler.rb +15 -0
- data/lib/pug-ruby/system-compiler.rb +15 -0
- data/lib/pug-ruby/version.rb +7 -0
- data/package.json +11 -0
- data/pug-ruby.gemspec +19 -12
- data/support/browserify-jade-runtime.js +19 -0
- data/support/browserify-jade.js +17 -0
- data/support/browserify-pug-runtime.js +19 -0
- data/support/browserify-pug.js +23 -0
- data/support/minify-jade.js +11 -0
- data/support/minify-pug.js +11 -0
- data/test/helper.rb +202 -0
- data/test/jade/includes/includes/footer.jade +1 -1
- data/test/manual.html +21 -0
- data/test/manual.rb +25 -0
- data/test/pug/includes/includes/footer.pug +1 -1
- data/test/pug/index.pug +3 -3
- data/test/test-jade.rb +3 -67
- data/test/test-pug.rb +3 -67
- data/vendor/jade-1.0.0.min.js +1 -0
- data/vendor/jade-1.0.1.min.js +1 -0
- data/vendor/jade-1.0.2.min.js +1 -0
- data/vendor/jade-1.1.0.min.js +1 -0
- data/vendor/jade-1.1.1.min.js +1 -0
- data/vendor/jade-1.1.2.min.js +1 -0
- data/vendor/jade-1.1.3.min.js +1 -0
- data/vendor/jade-1.1.4.min.js +1 -0
- data/vendor/jade-1.1.5.min.js +1 -0
- data/vendor/jade-1.10.0.min.js +1 -0
- data/vendor/jade-1.11.0.min.js +1 -0
- data/vendor/jade-1.2.0.min.js +1 -0
- data/vendor/jade-1.3.0.min.js +1 -0
- data/vendor/jade-1.3.1.min.js +1 -0
- data/vendor/jade-1.4.0.min.js +1 -0
- data/vendor/jade-1.4.1.min.js +1 -0
- data/vendor/jade-1.4.2.min.js +1 -0
- data/vendor/jade-1.5.0.min.js +1 -0
- data/vendor/jade-1.6.0.min.js +1 -0
- data/vendor/jade-1.7.0.min.js +1 -0
- data/vendor/jade-1.8.0.min.js +1 -0
- data/vendor/jade-1.8.1.min.js +1 -0
- data/vendor/jade-1.8.2.min.js +1 -0
- data/vendor/jade-1.9.0.min.js +1 -0
- data/vendor/jade-1.9.1.min.js +1 -0
- data/vendor/jade-1.9.2.min.js +1 -0
- data/vendor/jade-runtime-1.0.0-license +22 -0
- data/vendor/jade-runtime-1.0.0.js +199 -0
- data/vendor/jade-runtime-1.0.1-license +22 -0
- data/vendor/jade-runtime-1.0.1.js +199 -0
- data/vendor/jade-runtime-1.0.2-license +22 -0
- data/vendor/jade-runtime-1.0.2.js +199 -0
- data/vendor/jade-runtime-1.1.0-license +22 -0
- data/vendor/jade-runtime-1.1.0.js +199 -0
- data/vendor/jade-runtime-1.1.1-license +22 -0
- data/vendor/jade-runtime-1.1.1.js +199 -0
- data/vendor/jade-runtime-1.1.2-license +22 -0
- data/vendor/jade-runtime-1.1.2.js +200 -0
- data/vendor/jade-runtime-1.1.3-license +22 -0
- data/vendor/jade-runtime-1.1.3.js +200 -0
- data/vendor/jade-runtime-1.1.4-license +22 -0
- data/vendor/jade-runtime-1.1.4.js +200 -0
- data/vendor/jade-runtime-1.1.5-license +22 -0
- data/vendor/jade-runtime-1.1.5.js +200 -0
- data/vendor/jade-runtime-1.10.0-license +22 -0
- data/vendor/jade-runtime-1.10.0.js +233 -0
- data/vendor/jade-runtime-1.11.0-license +22 -0
- data/vendor/jade-runtime-1.11.0.js +246 -0
- data/vendor/jade-runtime-1.2.0-license +22 -0
- data/vendor/jade-runtime-1.2.0.js +200 -0
- data/vendor/jade-runtime-1.3.0-license +22 -0
- data/vendor/jade-runtime-1.3.0.js +200 -0
- data/vendor/jade-runtime-1.3.1-license +22 -0
- data/vendor/jade-runtime-1.3.1.js +200 -0
- data/vendor/jade-runtime-1.4.0-license +22 -0
- data/vendor/jade-runtime-1.4.0.js +200 -0
- data/vendor/jade-runtime-1.4.1-license +22 -0
- data/vendor/jade-runtime-1.4.1.js +200 -0
- data/vendor/jade-runtime-1.4.2-license +22 -0
- data/vendor/jade-runtime-1.4.2.js +200 -0
- data/vendor/jade-runtime-1.5.0-license +22 -0
- data/vendor/jade-runtime-1.5.0.js +200 -0
- data/vendor/jade-runtime-1.6.0-license +22 -0
- data/vendor/jade-runtime-1.6.0.js +200 -0
- data/vendor/jade-runtime-1.7.0-license +22 -0
- data/vendor/jade-runtime-1.7.0.js +200 -0
- data/vendor/jade-runtime-1.8.0-license +22 -0
- data/vendor/jade-runtime-1.8.0.js +228 -0
- data/vendor/jade-runtime-1.8.1-license +22 -0
- data/vendor/jade-runtime-1.8.1.js +228 -0
- data/vendor/jade-runtime-1.8.2-license +22 -0
- data/vendor/jade-runtime-1.8.2.js +228 -0
- data/vendor/jade-runtime-1.9.0-license +22 -0
- data/vendor/jade-runtime-1.9.0.js +228 -0
- data/vendor/jade-runtime-1.9.1-license +22 -0
- data/vendor/jade-runtime-1.9.1.js +228 -0
- data/vendor/jade-runtime-1.9.2-license +22 -0
- data/vendor/jade-runtime-1.9.2.js +228 -0
- data/vendor/pug-2.0.0-beta.12-license +22 -0
- data/vendor/pug-2.0.0-beta.12.min.js +1 -0
- data/vendor/pug-2.0.0-beta1-license +22 -0
- data/vendor/pug-2.0.0-beta1.min.js +1 -0
- data/vendor/pug-2.0.0-beta10-license +22 -0
- data/vendor/pug-2.0.0-beta10.min.js +1 -0
- data/vendor/pug-2.0.0-beta11-license +22 -0
- data/vendor/pug-2.0.0-beta11.min.js +1 -0
- data/vendor/pug-2.0.0-beta2-license +22 -0
- data/vendor/pug-2.0.0-beta2.min.js +1 -0
- data/vendor/pug-2.0.0-beta3-license +22 -0
- data/vendor/pug-2.0.0-beta3.min.js +1 -0
- data/vendor/pug-2.0.0-beta4-license +22 -0
- data/vendor/pug-2.0.0-beta4.min.js +1 -0
- data/vendor/pug-2.0.0-beta5-license +22 -0
- data/vendor/pug-2.0.0-beta5.min.js +1 -0
- data/vendor/pug-2.0.0-beta6-license +22 -0
- data/vendor/pug-2.0.0-beta6.min.js +1 -0
- data/vendor/pug-2.0.0-beta7-license +22 -0
- data/vendor/pug-2.0.0-beta7.min.js +1 -0
- data/vendor/pug-2.0.0-beta8-license +22 -0
- data/vendor/pug-2.0.0-beta8.min.js +1 -0
- data/vendor/pug-2.0.0-beta9-license +22 -0
- data/vendor/pug-2.0.0-beta9.min.js +1 -0
- data/vendor/pug-2.0.0-rc.1-license +22 -0
- data/vendor/pug-2.0.0-rc.1.min.js +1 -0
- data/vendor/pug-2.0.0-rc.2-license +22 -0
- data/vendor/pug-2.0.0-rc.2.min.js +1 -0
- data/vendor/pug-2.0.0-rc.3-license +22 -0
- data/vendor/pug-2.0.0-rc.3.min.js +1 -0
- data/vendor/pug-runtime-2.0.0-license +19 -0
- data/vendor/pug-runtime-2.0.0.js +266 -0
- data/vendor/pug-runtime-2.0.1-license +19 -0
- data/vendor/pug-runtime-2.0.1.js +266 -0
- data/vendor/pug-runtime-2.0.2-license +19 -0
- data/vendor/pug-runtime-2.0.2.js +267 -0
- metadata +242 -13
- data/lib/jade-ruby/compile.rb +0 -79
- data/lib/pug-ruby/compile.rb +0 -88
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module JadePug
|
|
5
|
+
#
|
|
6
|
+
# Used for template compilation errors, for example:
|
|
7
|
+
# - any template engine errors
|
|
8
|
+
# - syntax errors in template
|
|
9
|
+
# - any JavaScript exceptions (they are caught by ExecJS)
|
|
10
|
+
#
|
|
11
|
+
class CompilationError < StandardError
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module JadePug
|
|
5
|
+
#
|
|
6
|
+
# Used when something is wrong with shipped engine compiler, for example:
|
|
7
|
+
# - when compiler source couldn't be read (file is missing or permissions problem?)
|
|
8
|
+
# - when compiler couldn't be compiled (when ExecJS fails to compile JavaScript code)
|
|
9
|
+
#
|
|
10
|
+
class CompilerError < StandardError
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "execjs"
|
|
5
|
+
|
|
6
|
+
module JadePug
|
|
7
|
+
#
|
|
8
|
+
# Abstraction layer for shipped engine compiler.
|
|
9
|
+
#
|
|
10
|
+
class ShippedCompiler < Compiler
|
|
11
|
+
#
|
|
12
|
+
# @param engine [Jade, Pug] The Jade or Pug module.
|
|
13
|
+
# @param version [String]
|
|
14
|
+
def initialize(engine, version)
|
|
15
|
+
super
|
|
16
|
+
@execjs = compile_compiler_source(read_compiler_source(path_to_compiler_source))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
#
|
|
20
|
+
# Compiles template.
|
|
21
|
+
#
|
|
22
|
+
# @param source [String, #read]
|
|
23
|
+
# @param options [Hash]
|
|
24
|
+
# @return [String]
|
|
25
|
+
def compile(source, options = {})
|
|
26
|
+
source = prepare_source(source)
|
|
27
|
+
options = prepare_options(options)
|
|
28
|
+
snippet = compilation_snippet \
|
|
29
|
+
method: "compile#{"Client" if options[:client]}",
|
|
30
|
+
arguments: [source, options],
|
|
31
|
+
locals: options.fetch(:locals, {}),
|
|
32
|
+
options: options
|
|
33
|
+
result = @execjs.eval(snippet)
|
|
34
|
+
process_result(source, result, options)
|
|
35
|
+
rescue ExecJS::ProgramError => e
|
|
36
|
+
raise engine::CompilationError, e.message
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
protected
|
|
40
|
+
|
|
41
|
+
#
|
|
42
|
+
# Returns absolute path to the file with compiler source.
|
|
43
|
+
#
|
|
44
|
+
# @return [String]
|
|
45
|
+
def path_to_compiler_source
|
|
46
|
+
File.expand_path("../../../vendor/#{engine.name.downcase}-#{version}.min.js", __FILE__)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
#
|
|
50
|
+
# Reads the compiler source from a file and returns it.
|
|
51
|
+
#
|
|
52
|
+
# @param path [String]
|
|
53
|
+
# @return [String]
|
|
54
|
+
def read_compiler_source(path)
|
|
55
|
+
unless File.readable?(path)
|
|
56
|
+
raise engine::CompilerError, "Couldn't read compiler source: #{path}"
|
|
57
|
+
end
|
|
58
|
+
File.read(path)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Compiles the compiler from source and returns it as {ExecJS::Runtime}.
|
|
63
|
+
#
|
|
64
|
+
# @param source [String]
|
|
65
|
+
# @return [ExecJS::Runtime]
|
|
66
|
+
def compile_compiler_source(source)
|
|
67
|
+
ExecJS.compile(source).tap do |compiler|
|
|
68
|
+
raise engine::CompilerError, "Failed to compile #{engine.name} compiler" unless compiler
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
#
|
|
73
|
+
# Returns the JavaScript code used to access engine NPM package.
|
|
74
|
+
#
|
|
75
|
+
# @return [String]
|
|
76
|
+
def npm_package_require_snippet
|
|
77
|
+
engine.name.downcase
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "open3"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module JadePug
|
|
8
|
+
#
|
|
9
|
+
# Abstraction layer for system engine compiler.
|
|
10
|
+
#
|
|
11
|
+
class SystemCompiler < Compiler
|
|
12
|
+
#
|
|
13
|
+
# @param engine [Jade, Pug]
|
|
14
|
+
def initialize(engine)
|
|
15
|
+
super(engine, nil)
|
|
16
|
+
|
|
17
|
+
check_node_runtime!
|
|
18
|
+
check_npm_package!
|
|
19
|
+
|
|
20
|
+
engine.echo "Resolved system #{engine.name} to #{version}."
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#
|
|
24
|
+
# Compiles the template.
|
|
25
|
+
#
|
|
26
|
+
# @param source [String, #read]
|
|
27
|
+
# @param options [hash]
|
|
28
|
+
# @return [String]
|
|
29
|
+
def compile(source, options = {})
|
|
30
|
+
source = prepare_source(source)
|
|
31
|
+
options = prepare_options(options)
|
|
32
|
+
command = ["node", "--eval"]
|
|
33
|
+
command.push compilation_snippet \
|
|
34
|
+
method: "compile#{"Client" if options[:client]}",
|
|
35
|
+
arguments: [source, options],
|
|
36
|
+
locals: options.fetch(:locals, {}),
|
|
37
|
+
options: options
|
|
38
|
+
stdout, stderr, exit_status = Open3.capture3(*command)
|
|
39
|
+
raise engine::CompilationError, stderr unless exit_status.success?
|
|
40
|
+
process_result(source, stdout, options)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Returns version of engine installed system-wide.
|
|
45
|
+
#
|
|
46
|
+
# @return [String]
|
|
47
|
+
def version
|
|
48
|
+
stdout, exit_status = Open3.capture2 "node", "--eval", \
|
|
49
|
+
"console.log(require(#{ JSON.dump(File.join(npm_package_path, "package.json")) }).version)"
|
|
50
|
+
|
|
51
|
+
if exit_status.success?
|
|
52
|
+
stdout.strip
|
|
53
|
+
else
|
|
54
|
+
raise engine::CompilerError, \
|
|
55
|
+
%{Failed to get #{engine.name} version. Perhaps, the problem with Node.js runtime.}
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
memoize :version
|
|
59
|
+
|
|
60
|
+
protected
|
|
61
|
+
|
|
62
|
+
#
|
|
63
|
+
# Return the name of engine NPM package.
|
|
64
|
+
#
|
|
65
|
+
# @return [String]
|
|
66
|
+
def npm_package_name
|
|
67
|
+
engine.name.downcase
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#
|
|
71
|
+
# Returns the path of globally installed engine NPM package.
|
|
72
|
+
#
|
|
73
|
+
# @return [String]
|
|
74
|
+
def npm_package_path
|
|
75
|
+
File.join(npm_packages_root, engine.name.downcase)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# Returns the JavaScript code used to require engine NPM package.
|
|
80
|
+
#
|
|
81
|
+
# @return [String]
|
|
82
|
+
def npm_package_require_snippet
|
|
83
|
+
"require(#{ JSON.dump(npm_package_path) })"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
#
|
|
87
|
+
# Returns the root directory of globally installed NPM packages.
|
|
88
|
+
#
|
|
89
|
+
# @return [String]
|
|
90
|
+
def npm_packages_root
|
|
91
|
+
stdout, exit_status = Open3.capture2("npm", "root", "--global")
|
|
92
|
+
|
|
93
|
+
if exit_status.success?
|
|
94
|
+
stdout.strip
|
|
95
|
+
else
|
|
96
|
+
raise engine::CompilerError, \
|
|
97
|
+
%{Unable to get NPM packages root. Perhaps, the problem with Node.js runtime.}
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
memoize :npm_packages_root
|
|
101
|
+
|
|
102
|
+
#
|
|
103
|
+
# Checks if Node.js runtime exists in $PATH and is accessible.
|
|
104
|
+
#
|
|
105
|
+
# @raise {JadePug::CompilerError}
|
|
106
|
+
# If Node.js runtime doesn't exist in system.
|
|
107
|
+
# @return [nil]
|
|
108
|
+
def check_node_runtime!
|
|
109
|
+
stdout, exit_status = Open3.capture2("node", "--version")
|
|
110
|
+
|
|
111
|
+
if exit_status.success?
|
|
112
|
+
@node_version = stdout.strip.gsub(/\Av/, "")
|
|
113
|
+
engine.echo "Using Node.js runtime #{@node_version}."
|
|
114
|
+
else
|
|
115
|
+
raise engine::CompilerError, %{No Node.js runtime has been found in your system.}
|
|
116
|
+
end
|
|
117
|
+
nil
|
|
118
|
+
end
|
|
119
|
+
memoize :check_node_runtime!
|
|
120
|
+
|
|
121
|
+
#
|
|
122
|
+
# Checks if engine NPM package has been installed.
|
|
123
|
+
#
|
|
124
|
+
# @raise {JadePug::CompilerError}
|
|
125
|
+
# If engine NPM package han't been installed.
|
|
126
|
+
# @return [nil]
|
|
127
|
+
def check_npm_package!
|
|
128
|
+
exit_status = Open3.capture2("node", "--eval", npm_package_require_snippet)[1]
|
|
129
|
+
|
|
130
|
+
unless exit_status.success?
|
|
131
|
+
raise engine::CompilerError, \
|
|
132
|
+
%{No #{engine.name} NPM package has been found in your system. } +
|
|
133
|
+
%{Have you forgotten to "npm install --global #{npm_package_name}"?}
|
|
134
|
+
end
|
|
135
|
+
nil
|
|
136
|
+
end
|
|
137
|
+
memoize :check_npm_package!
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Jade
|
|
5
|
+
#
|
|
6
|
+
# Used to share common things between compilers.
|
|
7
|
+
#
|
|
8
|
+
module CompilationEssentials
|
|
9
|
+
#
|
|
10
|
+
# Responds for post-processing compilation result.
|
|
11
|
+
#
|
|
12
|
+
# @param source [String] The source code of template.
|
|
13
|
+
# @param result [String] The compiled code of template.
|
|
14
|
+
# @param options [Hash] The compilation options.
|
|
15
|
+
# @return [String]
|
|
16
|
+
def process_result(source, result, options)
|
|
17
|
+
if options[:client]
|
|
18
|
+
"(function(jade) { #{super}; return #{options[:name]}; }).call(this, jade);"
|
|
19
|
+
else
|
|
20
|
+
super
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/jade-ruby/config.rb
CHANGED
|
@@ -1,51 +1,24 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: UTF-8
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
module Jade
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
attr_accessor :compile_debug
|
|
14
|
-
attr_accessor :cache
|
|
15
|
-
attr_accessor :globals
|
|
16
|
-
attr_accessor :client
|
|
17
|
-
attr_accessor :name
|
|
18
|
-
attr_accessor :name_after_file
|
|
19
|
-
attr_accessor :out
|
|
20
|
-
attr_accessor :extension
|
|
21
|
-
attr_accessor :hierarchy
|
|
22
|
-
|
|
5
|
+
#
|
|
6
|
+
# Defines Jade compiler configuration.
|
|
7
|
+
#
|
|
8
|
+
# The documentation for Jade configuration options can be found here:
|
|
9
|
+
# - {http://web.archive.org/web/*/jade-lang.com/api}
|
|
10
|
+
# - {https://github.com/pugjs/pug/blob/v1.x.x/bin/jade.js}
|
|
11
|
+
#
|
|
12
|
+
class Config < JadePug::Config
|
|
23
13
|
def initialize
|
|
24
|
-
|
|
25
|
-
@
|
|
26
|
-
@
|
|
27
|
-
@
|
|
28
|
-
@
|
|
29
|
-
@compile_debug
|
|
30
|
-
@
|
|
31
|
-
@
|
|
32
|
-
@client = false
|
|
33
|
-
@name = 'template'
|
|
34
|
-
@name_after_file = nil
|
|
35
|
-
@out = nil
|
|
36
|
-
@extension = nil
|
|
37
|
-
@hierarchy = false
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def to_hash
|
|
41
|
-
%i( filename doctype pretty
|
|
42
|
-
self debug compile_debug
|
|
43
|
-
cache globals client
|
|
44
|
-
name name_after_file out
|
|
45
|
-
extension hierarchy ).each_with_object({}) { |x, y| y[x] = send(x) }
|
|
14
|
+
super
|
|
15
|
+
@filename = nil
|
|
16
|
+
@doctype = nil
|
|
17
|
+
@pretty = false
|
|
18
|
+
@self = false
|
|
19
|
+
@compile_debug = false
|
|
20
|
+
@globals = []
|
|
21
|
+
@name = "template"
|
|
46
22
|
end
|
|
47
23
|
end
|
|
48
|
-
|
|
49
|
-
class << self; attr_accessor :config; end
|
|
50
|
-
self.config = Config.new
|
|
51
24
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Jade
|
|
5
|
+
#
|
|
6
|
+
# Used for template compilation errors, for example:
|
|
7
|
+
# - any template engine errors
|
|
8
|
+
# - syntax errors in template
|
|
9
|
+
# - any JavaScript exceptions (they are caught by ExecJS)
|
|
10
|
+
#
|
|
11
|
+
class CompilationError < JadePug::CompilationError
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Jade
|
|
5
|
+
#
|
|
6
|
+
# Used when something is wrong with shipped Jade compiler, for example:
|
|
7
|
+
# - when compiler source couldn't be read (file is missing or permissions problem?)
|
|
8
|
+
# - when compiler couldn't be compiled (when ExecJS fails to compile JavaScript code)
|
|
9
|
+
#
|
|
10
|
+
class CompilerError < JadePug::CompilerError
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Jade
|
|
5
|
+
#
|
|
6
|
+
# Abstraction layer for shipped Jade compiler.
|
|
7
|
+
#
|
|
8
|
+
class ShippedCompiler < JadePug::ShippedCompiler
|
|
9
|
+
include CompilationEssentials
|
|
10
|
+
|
|
11
|
+
def initialize(version)
|
|
12
|
+
super Jade, version
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Jade
|
|
5
|
+
#
|
|
6
|
+
# Abstraction layer for system Jade compiler.
|
|
7
|
+
#
|
|
8
|
+
class SystemCompiler < JadePug::SystemCompiler
|
|
9
|
+
include CompilationEssentials
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
super Jade
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/pug-ruby.rb
CHANGED
|
@@ -1,7 +1,48 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: UTF-8
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
#
|
|
5
|
+
# This module contains common thing related Jade and Pug.
|
|
6
|
+
#
|
|
7
|
+
module JadePug
|
|
8
|
+
autoload :Config, "jade-pug/config"
|
|
9
|
+
autoload :Compiler, "jade-pug/compiler"
|
|
10
|
+
autoload :ShippedCompiler, "jade-pug/shipped-compiler"
|
|
11
|
+
autoload :SystemCompiler, "jade-pug/system-compiler"
|
|
12
|
+
autoload :CompilationError, "jade-pug/errors/compilation-error"
|
|
13
|
+
autoload :CompilerError, "jade-pug/errors/compiler-error"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
require "jade-pug/base"
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
# This module contains all stuff related to Jade template engine.
|
|
20
|
+
# See the list below.
|
|
21
|
+
#
|
|
22
|
+
module Jade
|
|
23
|
+
extend JadePug
|
|
24
|
+
|
|
25
|
+
autoload :Config, "jade-ruby/config"
|
|
26
|
+
autoload :Compiler, "jade-ruby/compiler"
|
|
27
|
+
autoload :ShippedCompiler, "jade-ruby/shipped-compiler"
|
|
28
|
+
autoload :SystemCompiler, "jade-ruby/system-compiler"
|
|
29
|
+
autoload :CompilationEssentials, "jade-ruby/compilation-essentials"
|
|
30
|
+
autoload :CompilationError, "jade-ruby/errors/compilation-error"
|
|
31
|
+
autoload :CompilerError, "jade-ruby/errors/compiler-error"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
# This module contains all stuff related to Pug template engine.
|
|
36
|
+
# See the list below.
|
|
37
|
+
#
|
|
38
|
+
module Pug
|
|
39
|
+
extend JadePug
|
|
40
|
+
|
|
41
|
+
autoload :Config, "pug-ruby/config"
|
|
42
|
+
autoload :Compiler, "pug-ruby/compiler"
|
|
43
|
+
autoload :ShippedCompiler, "pug-ruby/shipped-compiler"
|
|
44
|
+
autoload :SystemCompiler, "pug-ruby/system-compiler"
|
|
45
|
+
autoload :CompilationEssentials, "pug-ruby/compilation-essentials"
|
|
46
|
+
autoload :CompilationError, "pug-ruby/errors/compilation-error"
|
|
47
|
+
autoload :CompilerError, "pug-ruby/errors/compiler-error"
|
|
48
|
+
end
|