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,29 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Pug
|
|
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
|
+
if options[:inline_runtime_functions]
|
|
19
|
+
"(function() { #{super}; return #{options[:name]}; }).call(this);"
|
|
20
|
+
else
|
|
21
|
+
pug = "typeof pugRuntime === 'object' && pugRuntime !== null ? pugRuntime : pug"
|
|
22
|
+
"(function(pug) { #{super}; return #{options[:name]}; }).call(this, #{pug});"
|
|
23
|
+
end
|
|
24
|
+
else
|
|
25
|
+
super
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/pug-ruby/config.rb
CHANGED
|
@@ -1,52 +1,26 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: UTF-8
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
4
|
module Pug
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
attr_accessor :debug
|
|
14
|
-
attr_accessor :compile_debug
|
|
15
|
-
attr_accessor :globals
|
|
16
|
-
attr_accessor :inline_runtime_functions
|
|
17
|
-
attr_accessor :name
|
|
18
|
-
attr_accessor :name_after_file
|
|
19
|
-
attr_accessor :out
|
|
20
|
-
attr_accessor :extension
|
|
21
|
-
attr_accessor :silent
|
|
22
|
-
|
|
5
|
+
#
|
|
6
|
+
# Defines Pug compiler configuration.
|
|
7
|
+
#
|
|
8
|
+
# The documentation for Pug configuration options can be found here:
|
|
9
|
+
# - {https://pugjs.org/api/reference.html}
|
|
10
|
+
# - {https://github.com/pugjs/pug-cli/blob/master/index.js}
|
|
11
|
+
#
|
|
12
|
+
class Config < JadePug::Config
|
|
23
13
|
def initialize
|
|
14
|
+
super
|
|
24
15
|
@filename = nil
|
|
25
16
|
@basedir = nil
|
|
26
17
|
@doctype = nil
|
|
27
18
|
@pretty = false
|
|
28
19
|
@self = false
|
|
29
|
-
@debug = false
|
|
30
20
|
@compile_debug = false
|
|
31
21
|
@globals = []
|
|
32
22
|
@inline_runtime_functions = true
|
|
33
|
-
@name =
|
|
34
|
-
@name_after_file = nil
|
|
35
|
-
@out = nil
|
|
36
|
-
@extension = nil
|
|
37
|
-
@silent = true
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def to_hash
|
|
41
|
-
%i( filename basedir doctype
|
|
42
|
-
pretty self debug
|
|
43
|
-
compile_debug globals inline_runtime_functions
|
|
44
|
-
name name_after_file out
|
|
45
|
-
extension silent ).each_with_object({}) { |x, y| y[x] = send(x) }
|
|
23
|
+
@name = "template"
|
|
46
24
|
end
|
|
47
25
|
end
|
|
48
|
-
|
|
49
|
-
singleton_class.class_exec { attr_accessor :config }
|
|
50
|
-
self.config = Config.new
|
|
51
26
|
end
|
|
52
|
-
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Pug
|
|
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 Pug
|
|
5
|
+
#
|
|
6
|
+
# Used when something is wrong with shipped Pug 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 Pug
|
|
5
|
+
#
|
|
6
|
+
# Abstraction layer for shipped Pug compiler.
|
|
7
|
+
#
|
|
8
|
+
class ShippedCompiler < JadePug::ShippedCompiler
|
|
9
|
+
include CompilationEssentials
|
|
10
|
+
|
|
11
|
+
def initialize(version)
|
|
12
|
+
super Pug, version
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Pug
|
|
5
|
+
#
|
|
6
|
+
# Abstraction layer for system Pug compiler.
|
|
7
|
+
#
|
|
8
|
+
class SystemCompiler < JadePug::SystemCompiler
|
|
9
|
+
include CompilationEssentials
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
super Pug
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/package.json
ADDED
data/pug-ruby.gemspec
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
# encoding:
|
|
1
|
+
# encoding: UTF-8
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
+
require File.expand_path("../lib/pug-ruby/version", __FILE__)
|
|
5
|
+
|
|
4
6
|
Gem::Specification.new do |s|
|
|
5
|
-
s.name =
|
|
6
|
-
s.version =
|
|
7
|
-
s.author =
|
|
8
|
-
s.email =
|
|
9
|
-
s.summary =
|
|
10
|
-
s.description =
|
|
11
|
-
s.homepage =
|
|
12
|
-
s.license =
|
|
7
|
+
s.name = "pug-ruby"
|
|
8
|
+
s.version = PUG_RUBY_GEM_VERSION
|
|
9
|
+
s.author = "Yaroslav Konoplov"
|
|
10
|
+
s.email = "eahome00@gmail.com"
|
|
11
|
+
s.summary = "Ruby wrapper for the Jade / Pug template engine."
|
|
12
|
+
s.description = "Ruby wrapper for the Jade / Pug template engine."
|
|
13
|
+
s.homepage = "https://github.com/yivo/pug-ruby"
|
|
14
|
+
s.license = "MIT"
|
|
13
15
|
|
|
14
16
|
s.files = `git ls-files -z`.split("\x0")
|
|
15
17
|
s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
|
|
16
|
-
s.require_paths = [
|
|
18
|
+
s.require_paths = ["lib"]
|
|
17
19
|
|
|
18
|
-
s.
|
|
19
|
-
s.
|
|
20
|
+
s.add_dependency "execjs", "~> 2.0"
|
|
21
|
+
s.add_dependency "memoist", "~> 0.15"
|
|
22
|
+
s.add_dependency "regexp-match-polyfill", "~> 1.0", ">= 1.0.2"
|
|
23
|
+
s.add_dependency "method-not-implemented", "~> 1.0", ">= 1.0.1"
|
|
24
|
+
s.add_development_dependency "rake", "~> 10.0"
|
|
25
|
+
s.add_development_dependency "test-unit", "~> 3.1"
|
|
26
|
+
s.add_development_dependency "bundler", "~> 1.7"
|
|
20
27
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
process.env['NODE_ENV'] = 'production';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var browserify = require('browserify');
|
|
5
|
+
|
|
6
|
+
var ENGINE_RUNTIME_DIR = process.argv[2];
|
|
7
|
+
var ENGINE_RUNTIME_VER = process.argv[3];
|
|
8
|
+
var OUTPUT_FILE = process.argv[4];
|
|
9
|
+
|
|
10
|
+
var ENGINE_RUNTIME_INDEX = ENGINE_RUNTIME_DIR + '/lib/runtime.js';
|
|
11
|
+
|
|
12
|
+
browserify({entries: [ENGINE_RUNTIME_INDEX], standalone: 'jade'})
|
|
13
|
+
.transform('babelify', {
|
|
14
|
+
presets: ['es2015'],
|
|
15
|
+
plugins: ['transform-es2015-block-scoping']
|
|
16
|
+
})
|
|
17
|
+
.transform('envify')
|
|
18
|
+
.bundle()
|
|
19
|
+
.pipe(fs.createWriteStream(OUTPUT_FILE));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
process.env['NODE_ENV'] = 'production';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var browserify = require('browserify');
|
|
5
|
+
|
|
6
|
+
var ENGINE_DIR = process.argv[2];
|
|
7
|
+
var ENGINE_VERSION = process.argv[3];
|
|
8
|
+
var OUTPUT_FILE = process.argv[4];
|
|
9
|
+
|
|
10
|
+
browserify({entries: [ENGINE_DIR + '/lib/index.js'], standalone: 'jade'})
|
|
11
|
+
.transform('babelify', {
|
|
12
|
+
presets: ['es2015'],
|
|
13
|
+
plugins: ['transform-es2015-block-scoping']
|
|
14
|
+
})
|
|
15
|
+
.transform('envify')
|
|
16
|
+
.bundle()
|
|
17
|
+
.pipe(fs.createWriteStream(OUTPUT_FILE));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
process.env['NODE_ENV'] = 'production';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var browserify = require('browserify');
|
|
5
|
+
|
|
6
|
+
var ENGINE_RUNTIME_DIR = process.argv[2];
|
|
7
|
+
var ENGINE_RUNTIME_VER = process.argv[3];
|
|
8
|
+
var OUTPUT_FILE = process.argv[4];
|
|
9
|
+
|
|
10
|
+
var ENGINE_RUNTIME_INDEX = ENGINE_RUNTIME_DIR + '/index.js';
|
|
11
|
+
|
|
12
|
+
browserify({entries: [ENGINE_RUNTIME_INDEX], standalone: 'pugRuntime'})
|
|
13
|
+
.transform('babelify', {
|
|
14
|
+
presets: ['es2015'],
|
|
15
|
+
plugins: ['transform-es2015-block-scoping']
|
|
16
|
+
})
|
|
17
|
+
.transform('envify')
|
|
18
|
+
.bundle()
|
|
19
|
+
.pipe(fs.createWriteStream(OUTPUT_FILE));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
process.env['NODE_ENV'] = 'production';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var browserify = require('browserify');
|
|
5
|
+
|
|
6
|
+
var ENGINE_DIR = process.argv[2];
|
|
7
|
+
var ENGINE_VERSION = process.argv[3];
|
|
8
|
+
var OUTPUT_FILE = process.argv[4];
|
|
9
|
+
|
|
10
|
+
var ENGINE_INDEX = fs.existsSync(ENGINE_DIR + '/packages/pug/lib/index.js') ?
|
|
11
|
+
ENGINE_DIR + '/packages/pug/lib/index.js' :
|
|
12
|
+
ENGINE_DIR + '/lib/index.js';
|
|
13
|
+
|
|
14
|
+
browserify({entries: [ENGINE_INDEX], standalone: 'pug'})
|
|
15
|
+
.transform('babelify', {
|
|
16
|
+
global: true,
|
|
17
|
+
only: /\/node_modules\/pug-/,
|
|
18
|
+
presets: ['es2015'],
|
|
19
|
+
plugins: ['transform-es2015-block-scoping']
|
|
20
|
+
})
|
|
21
|
+
.transform('envify')
|
|
22
|
+
.bundle()
|
|
23
|
+
.pipe(fs.createWriteStream(OUTPUT_FILE));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
process.env['NODE_ENV'] = 'production';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var uglifyJS = require('uglify-js');
|
|
5
|
+
|
|
6
|
+
var INPUT_FILE = process.argv[2];
|
|
7
|
+
var OUTPUT_FILE = INPUT_FILE;
|
|
8
|
+
|
|
9
|
+
var code = fs.readFileSync(INPUT_FILE, 'UTF-8');
|
|
10
|
+
|
|
11
|
+
fs.writeFileSync(OUTPUT_FILE, uglifyJS.minify(code, {compress: true, mangle: true}).code);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
process.env['NODE_ENV'] = 'production';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var uglifyJS = require('uglify-js');
|
|
5
|
+
|
|
6
|
+
var INPUT_FILE = process.argv[2];
|
|
7
|
+
var OUTPUT_FILE = INPUT_FILE;
|
|
8
|
+
|
|
9
|
+
var code = fs.readFileSync(INPUT_FILE, 'UTF-8');
|
|
10
|
+
|
|
11
|
+
fs.writeFileSync(OUTPUT_FILE, uglifyJS.minify(code, {compress: true, mangle: true}).code);
|
data/test/helper.rb
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
Bundler.require :default, :development
|
|
5
|
+
require "stringio"
|
|
6
|
+
require "regexp-match-polyfill"
|
|
7
|
+
|
|
8
|
+
Jade.silence = true
|
|
9
|
+
Pug.silence = true
|
|
10
|
+
|
|
11
|
+
module JadePugTestHelpers
|
|
12
|
+
def engine
|
|
13
|
+
Object.const_get self.class.name.gsub(/Test\z/, "")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def each_version
|
|
17
|
+
([:system] + engine.versions).each { |v| yield(v) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def ext
|
|
21
|
+
".#{engine.name.downcase}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def expand_path(relative_path)
|
|
25
|
+
File.expand_path(File.join("../#{engine.name.downcase}", relative_path), __FILE__)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def assert_match_doctype(string)
|
|
29
|
+
assert_match(doctype_regex, string)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def assert_no_match_doctype(string)
|
|
33
|
+
assert_no_match(doctype_regex, string)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def assert_match_template_function(string)
|
|
37
|
+
assert_match(template_function_regex, string)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def assert_no_match_template_function(string)
|
|
41
|
+
assert_no_match(template_function_regex, string)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def doctype_regex
|
|
45
|
+
/[<\\u003C]!DOCTYPE html[>\\u003E]/
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def template_function_regex
|
|
49
|
+
/function\s+#{engine.config.name}\s*\(locals\)\s*\{.*\}/m
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
module JadePugTest
|
|
54
|
+
def self.included(base)
|
|
55
|
+
base.class_eval do
|
|
56
|
+
include JadePugTestHelpers
|
|
57
|
+
|
|
58
|
+
versions = [:system] + Object.const_get(base.name.gsub(/Test\z/, "")).versions
|
|
59
|
+
versions = [:system] if ENV["QUICK"]
|
|
60
|
+
|
|
61
|
+
versions.each do |version|
|
|
62
|
+
test "compilation_#{version}" do
|
|
63
|
+
engine.use version
|
|
64
|
+
result = engine.compile("div Hello, world!")
|
|
65
|
+
assert_no_match_template_function(result)
|
|
66
|
+
assert_no_match_doctype(result)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
test "compilation_with_doctype_#{version}" do
|
|
70
|
+
engine.use version
|
|
71
|
+
result = engine.compile(File.read(expand_path("index#{ext}")))
|
|
72
|
+
assert_no_match_template_function(result)
|
|
73
|
+
assert_match_doctype(result)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
test "compilation_with_io_#{version}" do
|
|
77
|
+
engine.use version
|
|
78
|
+
template = "div\n | Hello, world!"
|
|
79
|
+
io = StringIO.new(template)
|
|
80
|
+
assert_equal(engine.compile(template), engine.compile(io))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
test "compilation_with_syntax_error_#{version}" do
|
|
84
|
+
engine.use version
|
|
85
|
+
assert_raise(engine::CompilationError) { engine.compile("else\n div") }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
test "client_compilation_#{version}" do
|
|
89
|
+
engine.use version
|
|
90
|
+
result = engine.compile("div Hello, world!", client: true)
|
|
91
|
+
assert_match_template_function(result)
|
|
92
|
+
assert_no_match_doctype(result)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
test "client_compilation_with_doctype_#{version}" do
|
|
96
|
+
engine.use version
|
|
97
|
+
result = engine.compile(File.read(expand_path("index#{ext}")), client: true)
|
|
98
|
+
assert_match_template_function(result)
|
|
99
|
+
assert_match_doctype(result)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
test "compilation_with_locals_#{version}" do
|
|
103
|
+
engine.use version
|
|
104
|
+
template = "div=greeting"
|
|
105
|
+
result = engine.compile(template, locals: { greeting: "Hello, world!" })
|
|
106
|
+
assert_no_match_template_function(result)
|
|
107
|
+
assert_match("Hello, world!", result)
|
|
108
|
+
assert_no_match(/greeting/, result)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
test "client_compilation_with_locals_#{version}" do
|
|
112
|
+
engine.use version
|
|
113
|
+
template = "div=greeting"
|
|
114
|
+
result = engine.compile(template, locals: { greeting: "Hello, world!" }, client: true)
|
|
115
|
+
assert_match_template_function(result)
|
|
116
|
+
assert_no_match(/Hello, world!/, result)
|
|
117
|
+
assert_match("greeting", result)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
test "switch_version_permanently_#{version}" do
|
|
121
|
+
engine.use version
|
|
122
|
+
assert_equal(version == :system ? engine.versions.last : version, engine.compiler.version)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
test "switch_version_temporarily_#{version}" do
|
|
126
|
+
was = engine.compiler.system? ? :system : engine.compiler.version
|
|
127
|
+
@called = false
|
|
128
|
+
engine.use(version) { @called = true }
|
|
129
|
+
assert_equal(engine.compiler.system? ? :system : engine.compiler.version, was)
|
|
130
|
+
assert @called
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_compilation_with_includes
|
|
137
|
+
engine.use :system
|
|
138
|
+
file = expand_path("includes/index#{ext}")
|
|
139
|
+
template = File.read(file)
|
|
140
|
+
result = engine.compile(template, filename: file)
|
|
141
|
+
assert_no_match_template_function(result)
|
|
142
|
+
assert_match_doctype(result)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def test_compilation_with_extends
|
|
146
|
+
engine.use :system
|
|
147
|
+
file = expand_path("extends/index#{ext}")
|
|
148
|
+
template = File.read(file)
|
|
149
|
+
result = engine.compile(template, filename: file)
|
|
150
|
+
assert_no_match_template_function(result)
|
|
151
|
+
assert_match_doctype(result)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def test_client_compilation_with_includes
|
|
155
|
+
engine.use :system
|
|
156
|
+
file = expand_path("includes/index#{ext}")
|
|
157
|
+
template = File.read(file)
|
|
158
|
+
result = engine.compile(template, filename: file, client: true)
|
|
159
|
+
assert_match_template_function(result)
|
|
160
|
+
assert_match_doctype(result)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_client_compilation_with_extends
|
|
164
|
+
engine.use :system
|
|
165
|
+
file = expand_path("extends/index#{ext}")
|
|
166
|
+
template = File.read(file)
|
|
167
|
+
result = engine.compile(template, filename: file, client: true)
|
|
168
|
+
assert_match_template_function(result)
|
|
169
|
+
assert_match_doctype(result)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def test_version_list
|
|
173
|
+
assert_equal engine == Jade ? "1.0.0" : "2.0.0-beta1", engine.versions.first
|
|
174
|
+
assert_equal engine == Jade ? "1.11.0" : "2.0.0-rc.3", engine.versions.last
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def test_runtime_version_list
|
|
178
|
+
assert_equal engine == Jade ? "1.0.0" : "2.0.0", engine.runtime_versions.first
|
|
179
|
+
assert_equal engine == Jade ? "1.11.0" : "2.0.2", engine.runtime_versions.last
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def test_config_serialization
|
|
183
|
+
[:filename, :doctype, :pretty].each do |option|
|
|
184
|
+
assert_include engine.config.to_h.keys, option
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def test_config_customization
|
|
189
|
+
engine.config.custom_option = "value"
|
|
190
|
+
assert_equal "value", engine.config.custom_option
|
|
191
|
+
assert engine.config.custom_option?
|
|
192
|
+
assert_include engine.config.to_h.keys, :custom_option
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def test_get_known_compiler
|
|
196
|
+
assert engine::ShippedCompiler === engine.compiler(engine.versions.sample)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def test_get_unknown_compiler
|
|
200
|
+
assert_raise(engine::CompilerError) { engine.compiler "0.0.0" }
|
|
201
|
+
end
|
|
202
|
+
end
|