pug-rails 2.0.3 → 3.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/.travis.yml +32 -13
- data/Appraisals +33 -11
- data/Gemfile +6 -6
- data/Gemfile.lock +70 -67
- data/{vendor/assets/javascripts/pug/LICENCE → LICENSE} +7 -5
- data/README.md +5 -5
- data/Rakefile +3 -8
- data/gemfiles/{rails_3.gemfile → rails_3.1.gemfile} +2 -2
- data/gemfiles/{rails_3.gemfile.lock → rails_3.1.gemfile.lock} +11 -11
- data/gemfiles/rails_3.2.gemfile +9 -0
- data/gemfiles/rails_3.2.gemfile.lock +124 -0
- data/gemfiles/rails_4.1_with_sprockets_2.gemfile +9 -0
- data/gemfiles/rails_4.1_with_sprockets_2.gemfile.lock +140 -0
- data/gemfiles/{rails_4_with_sprockets_3.gemfile → rails_4.1_with_sprockets_3.gemfile} +2 -2
- data/gemfiles/{rails_4_with_sprockets_3.gemfile.lock → rails_4.1_with_sprockets_3.gemfile.lock} +46 -48
- data/gemfiles/rails_4.2_with_sprockets_2.gemfile +9 -0
- data/gemfiles/rails_4.2_with_sprockets_2.gemfile.lock +140 -0
- data/gemfiles/{rails_4_with_sprockets_2.gemfile → rails_4.2_with_sprockets_3.gemfile} +2 -2
- data/gemfiles/{rails_4_with_sprockets_2.gemfile.lock → rails_4.2_with_sprockets_3.gemfile.lock} +46 -48
- data/gemfiles/{rails_5.gemfile → rails_5.0.gemfile} +2 -2
- data/gemfiles/{rails_5.gemfile.lock → rails_5.0.gemfile.lock} +59 -59
- data/gemfiles/rails_5.1.gemfile +9 -0
- data/gemfiles/rails_5.1.gemfile.lock +142 -0
- data/lib/jade-rails/railtie.rb +14 -14
- data/lib/jade-rails/sprockets/transformer.rb +28 -4
- data/lib/pug-rails.rb +8 -23
- data/lib/pug-rails/railtie.rb +14 -14
- data/lib/pug-rails/sprockets/transformer.rb +28 -4
- data/lib/pug-rails/version.rb +1 -0
- data/pug-rails.gemspec +18 -16
- data/test/fixtures/javascripts/{application.js → application-1.js} +0 -0
- data/test/fixtures/javascripts/application-1.js.expected +10 -0
- data/test/fixtures/javascripts/application-2.js +2 -0
- data/test/test-helper.rb +62 -0
- data/test/test-pug-rails.rb +21 -76
- metadata +33 -21
- data/vendor/assets/javascripts/jade/LICENCE +0 -22
- data/vendor/assets/javascripts/jade/runtime.js +0 -252
- data/vendor/assets/javascripts/pug/runtime.js +0 -259
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
(function() { this.JST || (this.JST = {}); this.JST["templates/jade"] = (function(jade) { function template(locals) {
|
2
|
+
var buf = [];
|
3
|
+
var jade_mixins = {};
|
4
|
+
var jade_interp;
|
5
|
+
|
6
|
+
buf.push("<div>Hello, Jade!</div>");;return buf.join("");
|
7
|
+
}; return template; }).call(this, jade);;
|
8
|
+
}).call(this);
|
9
|
+
(function() { this.JST || (this.JST = {}); this.JST["templates/pug"] = (function() { function template(locals) {var pug_html = "", pug_mixins = {}, pug_interp;pug_html = pug_html + "\u003Cdiv\u003EHello, Pug!\u003C\u002Fdiv\u003E";;return pug_html;}; return template; }).call(this);;
|
10
|
+
}).call(this);
|
data/test/test-helper.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
Bundler.require :default, :development
|
2
|
+
|
3
|
+
require "sprockets/railtie"
|
4
|
+
require "fileutils"
|
5
|
+
|
6
|
+
module TestHelper
|
7
|
+
def self.included(base)
|
8
|
+
base.setup do
|
9
|
+
clear_tmp
|
10
|
+
clear_logs
|
11
|
+
end
|
12
|
+
|
13
|
+
base.teardown do
|
14
|
+
clear_tmp
|
15
|
+
if defined?(Rails) && Rails.respond_to?(:application=)
|
16
|
+
Rails.application = nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_rails_application
|
22
|
+
Class.new(Rails::Application) do
|
23
|
+
config.eager_load = false
|
24
|
+
config.assets.enabled = true
|
25
|
+
config.assets.gzip = false
|
26
|
+
config.assets.paths = [Rails.root.join("test/fixtures/javascripts").to_s]
|
27
|
+
config.assets.precompile = []
|
28
|
+
config.paths["public"] = [Rails.root.join("tmp").to_s]
|
29
|
+
config.active_support.deprecation = :stderr
|
30
|
+
config.pug.compile_debug = false
|
31
|
+
config.jade.compile_debug = false
|
32
|
+
config.pug.pretty = false
|
33
|
+
config.jade.pretty = false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_sprockets_task(app)
|
38
|
+
require "sprockets/version" # Fix for sprockets 2.x
|
39
|
+
|
40
|
+
if Sprockets::VERSION.start_with?("2")
|
41
|
+
require "rake/sprocketstask"
|
42
|
+
Rake::SprocketsTask.new do |t|
|
43
|
+
t.environment = app.assets
|
44
|
+
t.output = "#{app.config.paths["public"].to_a[0]}#{app.config.assets.prefix}"
|
45
|
+
t.assets = app.config.assets.precompile
|
46
|
+
end
|
47
|
+
else
|
48
|
+
require "sprockets/rails/task"
|
49
|
+
Sprockets::Rails::Task.new(app)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def clear_tmp
|
54
|
+
FileUtils.rm_rf(File.expand_path("../../tmp", __FILE__))
|
55
|
+
end
|
56
|
+
|
57
|
+
def clear_logs
|
58
|
+
FileUtils.rm_rf(File.expand_path("../../log", __FILE__))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
Test::Unit::TestCase.send :include, TestHelper
|
data/test/test-pug-rails.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
-
# encoding:
|
1
|
+
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require 'sprockets/railtie'
|
6
|
-
require 'pug-rails'
|
7
|
-
require 'test/unit'
|
8
|
-
require 'fileutils'
|
4
|
+
require_relative "test-helper"
|
9
5
|
|
10
6
|
class PugRailsTest < Test::Unit::TestCase
|
11
7
|
def test_registration
|
@@ -13,93 +9,42 @@ class PugRailsTest < Test::Unit::TestCase
|
|
13
9
|
app.initialize!
|
14
10
|
|
15
11
|
if app.assets.respond_to?(:transformers)
|
16
|
-
assert app.assets.transformers.fetch(
|
17
|
-
|
12
|
+
assert app.assets.transformers.fetch("text/x-pug").fetch("application/javascript+function") \
|
13
|
+
== Pug::Sprockets::Transformer
|
14
|
+
assert app.assets.transformers.fetch("text/x-jade").fetch("application/javascript+function") \
|
15
|
+
== Jade::Sprockets::Transformer
|
18
16
|
end
|
19
17
|
|
20
18
|
if app.assets.respond_to?(:engines)
|
21
|
-
assert app.assets.engines.fetch(
|
22
|
-
assert app.assets.engines.fetch(
|
19
|
+
assert app.assets.engines.fetch(".pug") == Pug::Sprockets::Transformer
|
20
|
+
assert app.assets.engines.fetch(".jade") == Jade::Sprockets::Transformer
|
23
21
|
end
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
File.join(Gem::Specification.find_by_name("pug-ruby").gem_dir, "vendor").tap do |path|
|
24
|
+
assert app.assets.paths.include?(path)
|
25
|
+
end
|
28
26
|
end
|
29
27
|
|
30
28
|
def test_compilation
|
31
29
|
app = create_rails_application
|
32
30
|
app.initialize!
|
31
|
+
|
33
32
|
task = create_sprockets_task(app)
|
34
33
|
task.instance_exec { manifest.compile(assets) }
|
35
34
|
|
36
|
-
expected
|
37
|
-
|
38
|
-
var buf = [];
|
39
|
-
var jade_mixins = {};
|
40
|
-
var jade_interp;
|
41
|
-
|
42
|
-
buf.push("<div>Hello, Jade!</div>");;return buf.join("");
|
43
|
-
}; return template; }).call(this, jade);;
|
44
|
-
}).call(this);
|
45
|
-
(function() { this.JST || (this.JST = {}); this.JST["templates/pug"] = (function() { function template(locals) {var pug_html = "", pug_mixins = {}, pug_interp;pug_html = pug_html + "\\u003Cdiv\\u003EHello, Pug!\\u003C\\u002Fdiv\\u003E";;return pug_html;}; return template; }).call(this);;
|
46
|
-
}).call(this);
|
47
|
-
JAVASCRIPT
|
48
|
-
assert_equal expected, app.assets['application.js'].to_s.squish
|
49
|
-
end
|
50
|
-
|
51
|
-
def setup
|
52
|
-
super
|
53
|
-
clear_tmp
|
54
|
-
clear_logs
|
55
|
-
end
|
56
|
-
|
57
|
-
def teardown
|
58
|
-
super
|
59
|
-
clear_tmp
|
60
|
-
if defined?(Rails) && Rails.respond_to?(:application=)
|
61
|
-
Rails.application = nil
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
def create_rails_application
|
67
|
-
Class.new(Rails::Application) do
|
68
|
-
config.eager_load = false
|
69
|
-
config.assets.enabled = true
|
70
|
-
config.assets.gzip = false
|
71
|
-
config.assets.paths = [Rails.root.join('test/fixtures/javascripts').to_s]
|
72
|
-
config.assets.precompile = %w( application.js )
|
73
|
-
config.paths['public'] = [Rails.root.join('tmp').to_s]
|
74
|
-
config.active_support.deprecation = :stderr
|
75
|
-
config.pug.compile_debug = false
|
76
|
-
config.jade.compile_debug = false
|
77
|
-
config.pug.pretty = false
|
78
|
-
config.jade.pretty = false
|
35
|
+
File.expand_path("../fixtures/javascripts/application-1.js.expected", __FILE__).tap do |path|
|
36
|
+
assert_equal File.read(path).squish, app.assets["application-1.js"].to_s.squish
|
79
37
|
end
|
80
38
|
end
|
81
39
|
|
82
|
-
def
|
83
|
-
|
84
|
-
|
85
|
-
if Sprockets::VERSION.start_with?('2')
|
86
|
-
require 'rake/sprocketstask'
|
87
|
-
Rake::SprocketsTask.new do |t|
|
88
|
-
t.environment = app.assets
|
89
|
-
t.output = "#{app.config.paths['public'][0]}#{app.config.assets.prefix}"
|
90
|
-
t.assets = app.config.assets.precompile
|
91
|
-
end
|
92
|
-
else
|
93
|
-
require 'sprockets/rails/task'
|
94
|
-
Sprockets::Rails::Task.new(app)
|
95
|
-
end
|
96
|
-
end
|
40
|
+
def test_runtime
|
41
|
+
app = create_rails_application
|
42
|
+
app.initialize!
|
97
43
|
|
98
|
-
|
99
|
-
|
100
|
-
end
|
44
|
+
task = create_sprockets_task(app)
|
45
|
+
task.instance_exec { manifest.compile(assets) }
|
101
46
|
|
102
|
-
|
103
|
-
|
47
|
+
assert_match /pug_escape/, app.assets["application-2.js"].to_s
|
48
|
+
assert_match /jade_escape/, app.assets["application-2.js"].to_s
|
104
49
|
end
|
105
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pug-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pug-ruby
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,30 +111,39 @@ files:
|
|
111
111
|
- Appraisals
|
112
112
|
- Gemfile
|
113
113
|
- Gemfile.lock
|
114
|
+
- LICENSE
|
114
115
|
- README.md
|
115
116
|
- Rakefile
|
116
|
-
- gemfiles/rails_3.gemfile
|
117
|
-
- gemfiles/rails_3.gemfile.lock
|
118
|
-
- gemfiles/
|
119
|
-
- gemfiles/
|
120
|
-
- gemfiles/
|
121
|
-
- gemfiles/
|
122
|
-
- gemfiles/
|
123
|
-
- gemfiles/
|
117
|
+
- gemfiles/rails_3.1.gemfile
|
118
|
+
- gemfiles/rails_3.1.gemfile.lock
|
119
|
+
- gemfiles/rails_3.2.gemfile
|
120
|
+
- gemfiles/rails_3.2.gemfile.lock
|
121
|
+
- gemfiles/rails_4.1_with_sprockets_2.gemfile
|
122
|
+
- gemfiles/rails_4.1_with_sprockets_2.gemfile.lock
|
123
|
+
- gemfiles/rails_4.1_with_sprockets_3.gemfile
|
124
|
+
- gemfiles/rails_4.1_with_sprockets_3.gemfile.lock
|
125
|
+
- gemfiles/rails_4.2_with_sprockets_2.gemfile
|
126
|
+
- gemfiles/rails_4.2_with_sprockets_2.gemfile.lock
|
127
|
+
- gemfiles/rails_4.2_with_sprockets_3.gemfile
|
128
|
+
- gemfiles/rails_4.2_with_sprockets_3.gemfile.lock
|
129
|
+
- gemfiles/rails_5.0.gemfile
|
130
|
+
- gemfiles/rails_5.0.gemfile.lock
|
131
|
+
- gemfiles/rails_5.1.gemfile
|
132
|
+
- gemfiles/rails_5.1.gemfile.lock
|
124
133
|
- lib/jade-rails/railtie.rb
|
125
134
|
- lib/jade-rails/sprockets/transformer.rb
|
126
135
|
- lib/pug-rails.rb
|
127
136
|
- lib/pug-rails/railtie.rb
|
128
137
|
- lib/pug-rails/sprockets/transformer.rb
|
138
|
+
- lib/pug-rails/version.rb
|
129
139
|
- pug-rails.gemspec
|
130
|
-
- test/fixtures/javascripts/application.js
|
140
|
+
- test/fixtures/javascripts/application-1.js
|
141
|
+
- test/fixtures/javascripts/application-1.js.expected
|
142
|
+
- test/fixtures/javascripts/application-2.js
|
131
143
|
- test/fixtures/javascripts/templates/jade.jst.jade
|
132
144
|
- test/fixtures/javascripts/templates/pug.jst.pug
|
145
|
+
- test/test-helper.rb
|
133
146
|
- test/test-pug-rails.rb
|
134
|
-
- vendor/assets/javascripts/jade/LICENCE
|
135
|
-
- vendor/assets/javascripts/jade/runtime.js
|
136
|
-
- vendor/assets/javascripts/pug/LICENCE
|
137
|
-
- vendor/assets/javascripts/pug/runtime.js
|
138
147
|
homepage: https://github.com/yivo/pug-rails
|
139
148
|
licenses:
|
140
149
|
- MIT
|
@@ -150,17 +159,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
159
|
version: '0'
|
151
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
161
|
requirements:
|
153
|
-
- - "
|
162
|
+
- - ">"
|
154
163
|
- !ruby/object:Gem::Version
|
155
|
-
version:
|
164
|
+
version: 1.3.1
|
156
165
|
requirements: []
|
157
166
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.6.12
|
159
168
|
signing_key:
|
160
169
|
specification_version: 4
|
161
170
|
summary: Pug/Jade template engine integration with Rails asset pipeline.
|
162
171
|
test_files:
|
163
|
-
- test/fixtures/javascripts/application.js
|
172
|
+
- test/fixtures/javascripts/application-1.js
|
173
|
+
- test/fixtures/javascripts/application-1.js.expected
|
174
|
+
- test/fixtures/javascripts/application-2.js
|
164
175
|
- test/fixtures/javascripts/templates/jade.jst.jade
|
165
176
|
- test/fixtures/javascripts/templates/pug.jst.pug
|
177
|
+
- test/test-helper.rb
|
166
178
|
- test/test-pug-rails.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
(The MIT License)
|
2
|
-
|
3
|
-
Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
'Software'), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,252 +0,0 @@
|
|
1
|
-
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jade = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Merge two attribute objects giving precedence
|
6
|
-
* to values in object `b`. Classes are special-cased
|
7
|
-
* allowing for arrays and merging/joining appropriately
|
8
|
-
* resulting in a string.
|
9
|
-
*
|
10
|
-
* @param {Object} a
|
11
|
-
* @param {Object} b
|
12
|
-
* @return {Object} a
|
13
|
-
* @api private
|
14
|
-
*/
|
15
|
-
|
16
|
-
exports.merge = function merge(a, b) {
|
17
|
-
if (arguments.length === 1) {
|
18
|
-
var attrs = a[0];
|
19
|
-
for (var i = 1; i < a.length; i++) {
|
20
|
-
attrs = merge(attrs, a[i]);
|
21
|
-
}
|
22
|
-
return attrs;
|
23
|
-
}
|
24
|
-
var ac = a['class'];
|
25
|
-
var bc = b['class'];
|
26
|
-
|
27
|
-
if (ac || bc) {
|
28
|
-
ac = ac || [];
|
29
|
-
bc = bc || [];
|
30
|
-
if (!Array.isArray(ac)) ac = [ac];
|
31
|
-
if (!Array.isArray(bc)) bc = [bc];
|
32
|
-
a['class'] = ac.concat(bc).filter(nulls);
|
33
|
-
}
|
34
|
-
|
35
|
-
for (var key in b) {
|
36
|
-
if (key != 'class') {
|
37
|
-
a[key] = b[key];
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
return a;
|
42
|
-
};
|
43
|
-
|
44
|
-
/**
|
45
|
-
* Filter null `val`s.
|
46
|
-
*
|
47
|
-
* @param {*} val
|
48
|
-
* @return {Boolean}
|
49
|
-
* @api private
|
50
|
-
*/
|
51
|
-
|
52
|
-
function nulls(val) {
|
53
|
-
return val != null && val !== '';
|
54
|
-
}
|
55
|
-
|
56
|
-
/**
|
57
|
-
* join array as classes.
|
58
|
-
*
|
59
|
-
* @param {*} val
|
60
|
-
* @return {String}
|
61
|
-
*/
|
62
|
-
exports.joinClasses = joinClasses;
|
63
|
-
function joinClasses(val) {
|
64
|
-
return (Array.isArray(val) ? val.map(joinClasses) :
|
65
|
-
(val && typeof val === 'object') ? Object.keys(val).filter(function (key) { return val[key]; }) :
|
66
|
-
[val]).filter(nulls).join(' ');
|
67
|
-
}
|
68
|
-
|
69
|
-
/**
|
70
|
-
* Render the given classes.
|
71
|
-
*
|
72
|
-
* @param {Array} classes
|
73
|
-
* @param {Array.<Boolean>} escaped
|
74
|
-
* @return {String}
|
75
|
-
*/
|
76
|
-
exports.cls = function cls(classes, escaped) {
|
77
|
-
var buf = [];
|
78
|
-
for (var i = 0; i < classes.length; i++) {
|
79
|
-
if (escaped && escaped[i]) {
|
80
|
-
buf.push(exports.escape(joinClasses([classes[i]])));
|
81
|
-
} else {
|
82
|
-
buf.push(joinClasses(classes[i]));
|
83
|
-
}
|
84
|
-
}
|
85
|
-
var text = joinClasses(buf);
|
86
|
-
if (text.length) {
|
87
|
-
return ' class="' + text + '"';
|
88
|
-
} else {
|
89
|
-
return '';
|
90
|
-
}
|
91
|
-
};
|
92
|
-
|
93
|
-
|
94
|
-
exports.style = function (val) {
|
95
|
-
if (val && typeof val === 'object') {
|
96
|
-
return Object.keys(val).map(function (style) {
|
97
|
-
return style + ':' + val[style];
|
98
|
-
}).join(';');
|
99
|
-
} else {
|
100
|
-
return val;
|
101
|
-
}
|
102
|
-
};
|
103
|
-
/**
|
104
|
-
* Render the given attribute.
|
105
|
-
*
|
106
|
-
* @param {String} key
|
107
|
-
* @param {String} val
|
108
|
-
* @param {Boolean} escaped
|
109
|
-
* @param {Boolean} terse
|
110
|
-
* @return {String}
|
111
|
-
*/
|
112
|
-
exports.attr = function attr(key, val, escaped, terse) {
|
113
|
-
if (key === 'style') {
|
114
|
-
val = exports.style(val);
|
115
|
-
}
|
116
|
-
if ('boolean' == typeof val || null == val) {
|
117
|
-
if (val) {
|
118
|
-
return ' ' + (terse ? key : key + '="' + key + '"');
|
119
|
-
} else {
|
120
|
-
return '';
|
121
|
-
}
|
122
|
-
} else if (0 == key.indexOf('data') && 'string' != typeof val) {
|
123
|
-
if (JSON.stringify(val).indexOf('&') !== -1) {
|
124
|
-
console.warn('Since Jade 2.0.0, ampersands (`&`) in data attributes ' +
|
125
|
-
'will be escaped to `&`');
|
126
|
-
};
|
127
|
-
if (val && typeof val.toISOString === 'function') {
|
128
|
-
console.warn('Jade will eliminate the double quotes around dates in ' +
|
129
|
-
'ISO form after 2.0.0');
|
130
|
-
}
|
131
|
-
return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, ''') + "'";
|
132
|
-
} else if (escaped) {
|
133
|
-
if (val && typeof val.toISOString === 'function') {
|
134
|
-
console.warn('Jade will stringify dates in ISO form after 2.0.0');
|
135
|
-
}
|
136
|
-
return ' ' + key + '="' + exports.escape(val) + '"';
|
137
|
-
} else {
|
138
|
-
if (val && typeof val.toISOString === 'function') {
|
139
|
-
console.warn('Jade will stringify dates in ISO form after 2.0.0');
|
140
|
-
}
|
141
|
-
return ' ' + key + '="' + val + '"';
|
142
|
-
}
|
143
|
-
};
|
144
|
-
|
145
|
-
/**
|
146
|
-
* Render the given attributes object.
|
147
|
-
*
|
148
|
-
* @param {Object} obj
|
149
|
-
* @param {Object} escaped
|
150
|
-
* @return {String}
|
151
|
-
*/
|
152
|
-
exports.attrs = function attrs(obj, terse){
|
153
|
-
var buf = [];
|
154
|
-
|
155
|
-
var keys = Object.keys(obj);
|
156
|
-
|
157
|
-
if (keys.length) {
|
158
|
-
for (var i = 0; i < keys.length; ++i) {
|
159
|
-
var key = keys[i]
|
160
|
-
, val = obj[key];
|
161
|
-
|
162
|
-
if ('class' == key) {
|
163
|
-
if (val = joinClasses(val)) {
|
164
|
-
buf.push(' ' + key + '="' + val + '"');
|
165
|
-
}
|
166
|
-
} else {
|
167
|
-
buf.push(exports.attr(key, val, false, terse));
|
168
|
-
}
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
|
-
return buf.join('');
|
173
|
-
};
|
174
|
-
|
175
|
-
/**
|
176
|
-
* Escape the given string of `html`.
|
177
|
-
*
|
178
|
-
* @param {String} html
|
179
|
-
* @return {String}
|
180
|
-
* @api private
|
181
|
-
*/
|
182
|
-
|
183
|
-
var jade_encode_html_rules = {
|
184
|
-
'&': '&',
|
185
|
-
'<': '<',
|
186
|
-
'>': '>',
|
187
|
-
'"': '"'
|
188
|
-
};
|
189
|
-
var jade_match_html = /[&<>"]/g;
|
190
|
-
|
191
|
-
function jade_encode_char(c) {
|
192
|
-
return jade_encode_html_rules[c] || c;
|
193
|
-
}
|
194
|
-
|
195
|
-
exports.escape = jade_escape;
|
196
|
-
function jade_escape(html){
|
197
|
-
var result = String(html).replace(jade_match_html, jade_encode_char);
|
198
|
-
if (result === '' + html) return html;
|
199
|
-
else return result;
|
200
|
-
};
|
201
|
-
|
202
|
-
/**
|
203
|
-
* Re-throw the given `err` in context to the
|
204
|
-
* the jade in `filename` at the given `lineno`.
|
205
|
-
*
|
206
|
-
* @param {Error} err
|
207
|
-
* @param {String} filename
|
208
|
-
* @param {String} lineno
|
209
|
-
* @api private
|
210
|
-
*/
|
211
|
-
|
212
|
-
exports.rethrow = function rethrow(err, filename, lineno, str){
|
213
|
-
if (!(err instanceof Error)) throw err;
|
214
|
-
if ((typeof window != 'undefined' || !filename) && !str) {
|
215
|
-
err.message += ' on line ' + lineno;
|
216
|
-
throw err;
|
217
|
-
}
|
218
|
-
try {
|
219
|
-
str = str || require('fs').readFileSync(filename, 'utf8')
|
220
|
-
} catch (ex) {
|
221
|
-
rethrow(err, null, lineno)
|
222
|
-
}
|
223
|
-
var context = 3
|
224
|
-
, lines = str.split('\n')
|
225
|
-
, start = Math.max(lineno - context, 0)
|
226
|
-
, end = Math.min(lines.length, lineno + context);
|
227
|
-
|
228
|
-
// Error context
|
229
|
-
var context = lines.slice(start, end).map(function(line, i){
|
230
|
-
var curr = i + start + 1;
|
231
|
-
return (curr == lineno ? ' > ' : ' ')
|
232
|
-
+ curr
|
233
|
-
+ '| '
|
234
|
-
+ line;
|
235
|
-
}).join('\n');
|
236
|
-
|
237
|
-
// Alter exception message
|
238
|
-
err.path = filename;
|
239
|
-
err.message = (filename || 'Jade') + ':' + lineno
|
240
|
-
+ '\n' + context + '\n\n' + err.message;
|
241
|
-
throw err;
|
242
|
-
};
|
243
|
-
|
244
|
-
exports.DebugItem = function DebugItem(lineno, filename) {
|
245
|
-
this.lineno = lineno;
|
246
|
-
this.filename = filename;
|
247
|
-
}
|
248
|
-
|
249
|
-
},{"fs":2}],2:[function(require,module,exports){
|
250
|
-
|
251
|
-
},{}]},{},[1])(1)
|
252
|
-
});
|