pug-ruby 1.0.2 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- 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,19 @@
|
|
1
|
+
Copyright (c) 2014 Forbes Lindesay
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
@@ -0,0 +1,266 @@
|
|
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.pugRuntime = 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
|
+
|
3
|
+
},{}],2:[function(require,module,exports){
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
7
|
+
|
8
|
+
var pug_has_own_property = Object.prototype.hasOwnProperty;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Merge two attribute objects giving precedence
|
12
|
+
* to values in object `b`. Classes are special-cased
|
13
|
+
* allowing for arrays and merging/joining appropriately
|
14
|
+
* resulting in a string.
|
15
|
+
*
|
16
|
+
* @param {Object} a
|
17
|
+
* @param {Object} b
|
18
|
+
* @return {Object} a
|
19
|
+
* @api private
|
20
|
+
*/
|
21
|
+
|
22
|
+
exports.merge = pug_merge;
|
23
|
+
function pug_merge(a, b) {
|
24
|
+
if (arguments.length === 1) {
|
25
|
+
var attrs = a[0];
|
26
|
+
for (var i = 1; i < a.length; i++) {
|
27
|
+
attrs = pug_merge(attrs, a[i]);
|
28
|
+
}
|
29
|
+
return attrs;
|
30
|
+
}
|
31
|
+
|
32
|
+
for (var key in b) {
|
33
|
+
if (key === 'class') {
|
34
|
+
var valA = a[key] || [];
|
35
|
+
a[key] = (Array.isArray(valA) ? valA : [valA]).concat(b[key] || []);
|
36
|
+
} else if (key === 'style') {
|
37
|
+
var valA = pug_style(a[key]);
|
38
|
+
var valB = pug_style(b[key]);
|
39
|
+
a[key] = valA + (valA && valB && ';') + valB;
|
40
|
+
} else {
|
41
|
+
a[key] = b[key];
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
return a;
|
46
|
+
};
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Process array, object, or string as a string of classes delimited by a space.
|
50
|
+
*
|
51
|
+
* If `val` is an array, all members of it and its subarrays are counted as
|
52
|
+
* classes. If `escaping` is an array, then whether or not the item in `val` is
|
53
|
+
* escaped depends on the corresponding item in `escaping`. If `escaping` is
|
54
|
+
* not an array, no escaping is done.
|
55
|
+
*
|
56
|
+
* If `val` is an object, all the keys whose value is truthy are counted as
|
57
|
+
* classes. No escaping is done.
|
58
|
+
*
|
59
|
+
* If `val` is a string, it is counted as a class. No escaping is done.
|
60
|
+
*
|
61
|
+
* @param {(Array.<string>|Object.<string, boolean>|string)} val
|
62
|
+
* @param {?Array.<string>} escaping
|
63
|
+
* @return {String}
|
64
|
+
*/
|
65
|
+
exports.classes = pug_classes;
|
66
|
+
function pug_classes_array(val, escaping) {
|
67
|
+
var classString = '',
|
68
|
+
className,
|
69
|
+
padding = '',
|
70
|
+
escapeEnabled = Array.isArray(escaping);
|
71
|
+
for (var i = 0; i < val.length; i++) {
|
72
|
+
className = pug_classes(val[i]);
|
73
|
+
if (!className) continue;
|
74
|
+
escapeEnabled && escaping[i] && (className = pug_escape(className));
|
75
|
+
classString = classString + padding + className;
|
76
|
+
padding = ' ';
|
77
|
+
}
|
78
|
+
return classString;
|
79
|
+
}
|
80
|
+
function pug_classes_object(val) {
|
81
|
+
var classString = '',
|
82
|
+
padding = '';
|
83
|
+
for (var key in val) {
|
84
|
+
if (key && val[key] && pug_has_own_property.call(val, key)) {
|
85
|
+
classString = classString + padding + key;
|
86
|
+
padding = ' ';
|
87
|
+
}
|
88
|
+
}
|
89
|
+
return classString;
|
90
|
+
}
|
91
|
+
function pug_classes(val, escaping) {
|
92
|
+
if (Array.isArray(val)) {
|
93
|
+
return pug_classes_array(val, escaping);
|
94
|
+
} else if (val && (typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') {
|
95
|
+
return pug_classes_object(val);
|
96
|
+
} else {
|
97
|
+
return val || '';
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Convert object or string to a string of CSS styles delimited by a semicolon.
|
103
|
+
*
|
104
|
+
* @param {(Object.<string, string>|string)} val
|
105
|
+
* @return {String}
|
106
|
+
*/
|
107
|
+
|
108
|
+
exports.style = pug_style;
|
109
|
+
function pug_style(val) {
|
110
|
+
if (!val) return '';
|
111
|
+
if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') {
|
112
|
+
var out = '',
|
113
|
+
delim = '';
|
114
|
+
for (var style in val) {
|
115
|
+
/* istanbul ignore else */
|
116
|
+
if (pug_has_own_property.call(val, style)) {
|
117
|
+
out = out + delim + style + ':' + val[style];
|
118
|
+
delim = ';';
|
119
|
+
}
|
120
|
+
}
|
121
|
+
return out;
|
122
|
+
} else {
|
123
|
+
val = '' + val;
|
124
|
+
if (val[val.length - 1] === ';') return val.slice(0, -1);
|
125
|
+
return val;
|
126
|
+
}
|
127
|
+
};
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Render the given attribute.
|
131
|
+
*
|
132
|
+
* @param {String} key
|
133
|
+
* @param {String} val
|
134
|
+
* @param {Boolean} escaped
|
135
|
+
* @param {Boolean} terse
|
136
|
+
* @return {String}
|
137
|
+
*/
|
138
|
+
exports.attr = pug_attr;
|
139
|
+
function pug_attr(key, val, escaped, terse) {
|
140
|
+
if (val === false || val == null || !val && (key === 'class' || key === 'style')) {
|
141
|
+
return '';
|
142
|
+
}
|
143
|
+
if (val === true) {
|
144
|
+
return ' ' + (terse ? key : key + '="' + key + '"');
|
145
|
+
}
|
146
|
+
if (typeof val.toISOString === 'function') {
|
147
|
+
val = val.toISOString();
|
148
|
+
} else if (typeof val !== 'string') {
|
149
|
+
val = JSON.stringify(val);
|
150
|
+
if (!escaped && val.indexOf('"') !== -1) {
|
151
|
+
return ' ' + key + '=\'' + val.replace(/'/g, ''') + '\'';
|
152
|
+
}
|
153
|
+
}
|
154
|
+
if (escaped) val = pug_escape(val);
|
155
|
+
return ' ' + key + '="' + val + '"';
|
156
|
+
};
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Render the given attributes object.
|
160
|
+
*
|
161
|
+
* @param {Object} obj
|
162
|
+
* @param {Object} terse whether to use HTML5 terse boolean attributes
|
163
|
+
* @return {String}
|
164
|
+
*/
|
165
|
+
exports.attrs = pug_attrs;
|
166
|
+
function pug_attrs(obj, terse) {
|
167
|
+
var attrs = '';
|
168
|
+
|
169
|
+
for (var key in obj) {
|
170
|
+
if (pug_has_own_property.call(obj, key)) {
|
171
|
+
var val = obj[key];
|
172
|
+
|
173
|
+
if ('class' === key) {
|
174
|
+
val = pug_classes(val);
|
175
|
+
attrs = pug_attr(key, val, false, terse) + attrs;
|
176
|
+
continue;
|
177
|
+
}
|
178
|
+
if ('style' === key) {
|
179
|
+
val = pug_style(val);
|
180
|
+
}
|
181
|
+
attrs += pug_attr(key, val, false, terse);
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
return attrs;
|
186
|
+
};
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Escape the given string of `html`.
|
190
|
+
*
|
191
|
+
* @param {String} html
|
192
|
+
* @return {String}
|
193
|
+
* @api private
|
194
|
+
*/
|
195
|
+
|
196
|
+
var pug_match_html = /["&<>]/;
|
197
|
+
exports.escape = pug_escape;
|
198
|
+
function pug_escape(_html) {
|
199
|
+
var html = '' + _html;
|
200
|
+
var regexResult = pug_match_html.exec(html);
|
201
|
+
if (!regexResult) return _html;
|
202
|
+
|
203
|
+
var result = '';
|
204
|
+
var i, lastIndex, escape;
|
205
|
+
for (i = regexResult.index, lastIndex = 0; i < html.length; i++) {
|
206
|
+
switch (html.charCodeAt(i)) {
|
207
|
+
case 34:
|
208
|
+
escape = '"';break;
|
209
|
+
case 38:
|
210
|
+
escape = '&';break;
|
211
|
+
case 60:
|
212
|
+
escape = '<';break;
|
213
|
+
case 62:
|
214
|
+
escape = '>';break;
|
215
|
+
default:
|
216
|
+
continue;
|
217
|
+
}
|
218
|
+
if (lastIndex !== i) result += html.substring(lastIndex, i);
|
219
|
+
lastIndex = i + 1;
|
220
|
+
result += escape;
|
221
|
+
}
|
222
|
+
if (lastIndex !== i) return result + html.substring(lastIndex, i);else return result;
|
223
|
+
};
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Re-throw the given `err` in context to the
|
227
|
+
* the pug in `filename` at the given `lineno`.
|
228
|
+
*
|
229
|
+
* @param {Error} err
|
230
|
+
* @param {String} filename
|
231
|
+
* @param {String} lineno
|
232
|
+
* @param {String} str original source
|
233
|
+
* @api private
|
234
|
+
*/
|
235
|
+
|
236
|
+
exports.rethrow = pug_rethrow;
|
237
|
+
function pug_rethrow(err, filename, lineno, str) {
|
238
|
+
if (!(err instanceof Error)) throw err;
|
239
|
+
if ((typeof window != 'undefined' || !filename) && !str) {
|
240
|
+
err.message += ' on line ' + lineno;
|
241
|
+
throw err;
|
242
|
+
}
|
243
|
+
try {
|
244
|
+
str = str || require('fs').readFileSync(filename, 'utf8');
|
245
|
+
} catch (ex) {
|
246
|
+
pug_rethrow(err, null, lineno);
|
247
|
+
}
|
248
|
+
var context = 3,
|
249
|
+
lines = str.split('\n'),
|
250
|
+
start = Math.max(lineno - context, 0),
|
251
|
+
end = Math.min(lines.length, lineno + context);
|
252
|
+
|
253
|
+
// Error context
|
254
|
+
var context = lines.slice(start, end).map(function (line, i) {
|
255
|
+
var curr = i + start + 1;
|
256
|
+
return (curr == lineno ? ' > ' : ' ') + curr + '| ' + line;
|
257
|
+
}).join('\n');
|
258
|
+
|
259
|
+
// Alter exception message
|
260
|
+
err.path = filename;
|
261
|
+
err.message = (filename || 'Pug') + ':' + lineno + '\n' + context + '\n\n' + err.message;
|
262
|
+
throw err;
|
263
|
+
};
|
264
|
+
|
265
|
+
},{"fs":1}]},{},[2])(2)
|
266
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Forbes Lindesay
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
@@ -0,0 +1,267 @@
|
|
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.pugRuntime = 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
|
+
|
3
|
+
},{}],2:[function(require,module,exports){
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
7
|
+
|
8
|
+
var pug_has_own_property = Object.prototype.hasOwnProperty;
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Merge two attribute objects giving precedence
|
12
|
+
* to values in object `b`. Classes are special-cased
|
13
|
+
* allowing for arrays and merging/joining appropriately
|
14
|
+
* resulting in a string.
|
15
|
+
*
|
16
|
+
* @param {Object} a
|
17
|
+
* @param {Object} b
|
18
|
+
* @return {Object} a
|
19
|
+
* @api private
|
20
|
+
*/
|
21
|
+
|
22
|
+
exports.merge = pug_merge;
|
23
|
+
function pug_merge(a, b) {
|
24
|
+
if (arguments.length === 1) {
|
25
|
+
var attrs = a[0];
|
26
|
+
for (var i = 1; i < a.length; i++) {
|
27
|
+
attrs = pug_merge(attrs, a[i]);
|
28
|
+
}
|
29
|
+
return attrs;
|
30
|
+
}
|
31
|
+
|
32
|
+
for (var key in b) {
|
33
|
+
if (key === 'class') {
|
34
|
+
var valA = a[key] || [];
|
35
|
+
a[key] = (Array.isArray(valA) ? valA : [valA]).concat(b[key] || []);
|
36
|
+
} else if (key === 'style') {
|
37
|
+
var valA = pug_style(a[key]);
|
38
|
+
var valB = pug_style(b[key]);
|
39
|
+
a[key] = valA + (valA && valB && ';') + valB;
|
40
|
+
} else {
|
41
|
+
a[key] = b[key];
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
return a;
|
46
|
+
};
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Process array, object, or string as a string of classes delimited by a space.
|
50
|
+
*
|
51
|
+
* If `val` is an array, all members of it and its subarrays are counted as
|
52
|
+
* classes. If `escaping` is an array, then whether or not the item in `val` is
|
53
|
+
* escaped depends on the corresponding item in `escaping`. If `escaping` is
|
54
|
+
* not an array, no escaping is done.
|
55
|
+
*
|
56
|
+
* If `val` is an object, all the keys whose value is truthy are counted as
|
57
|
+
* classes. No escaping is done.
|
58
|
+
*
|
59
|
+
* If `val` is a string, it is counted as a class. No escaping is done.
|
60
|
+
*
|
61
|
+
* @param {(Array.<string>|Object.<string, boolean>|string)} val
|
62
|
+
* @param {?Array.<string>} escaping
|
63
|
+
* @return {String}
|
64
|
+
*/
|
65
|
+
exports.classes = pug_classes;
|
66
|
+
function pug_classes_array(val, escaping) {
|
67
|
+
var classString = '',
|
68
|
+
className,
|
69
|
+
padding = '',
|
70
|
+
escapeEnabled = Array.isArray(escaping);
|
71
|
+
for (var i = 0; i < val.length; i++) {
|
72
|
+
className = pug_classes(val[i]);
|
73
|
+
if (!className) continue;
|
74
|
+
escapeEnabled && escaping[i] && (className = pug_escape(className));
|
75
|
+
classString = classString + padding + className;
|
76
|
+
padding = ' ';
|
77
|
+
}
|
78
|
+
return classString;
|
79
|
+
}
|
80
|
+
function pug_classes_object(val) {
|
81
|
+
var classString = '',
|
82
|
+
padding = '';
|
83
|
+
for (var key in val) {
|
84
|
+
if (key && val[key] && pug_has_own_property.call(val, key)) {
|
85
|
+
classString = classString + padding + key;
|
86
|
+
padding = ' ';
|
87
|
+
}
|
88
|
+
}
|
89
|
+
return classString;
|
90
|
+
}
|
91
|
+
function pug_classes(val, escaping) {
|
92
|
+
if (Array.isArray(val)) {
|
93
|
+
return pug_classes_array(val, escaping);
|
94
|
+
} else if (val && (typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') {
|
95
|
+
return pug_classes_object(val);
|
96
|
+
} else {
|
97
|
+
return val || '';
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Convert object or string to a string of CSS styles delimited by a semicolon.
|
103
|
+
*
|
104
|
+
* @param {(Object.<string, string>|string)} val
|
105
|
+
* @return {String}
|
106
|
+
*/
|
107
|
+
|
108
|
+
exports.style = pug_style;
|
109
|
+
function pug_style(val) {
|
110
|
+
if (!val) return '';
|
111
|
+
if ((typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object') {
|
112
|
+
var out = '',
|
113
|
+
delim = '';
|
114
|
+
for (var style in val) {
|
115
|
+
/* istanbul ignore else */
|
116
|
+
if (pug_has_own_property.call(val, style)) {
|
117
|
+
out = out + delim + style + ':' + val[style];
|
118
|
+
delim = ';';
|
119
|
+
}
|
120
|
+
}
|
121
|
+
return out;
|
122
|
+
} else {
|
123
|
+
val = '' + val;
|
124
|
+
if (val[val.length - 1] === ';') return val.slice(0, -1);
|
125
|
+
return val;
|
126
|
+
}
|
127
|
+
};
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Render the given attribute.
|
131
|
+
*
|
132
|
+
* @param {String} key
|
133
|
+
* @param {String} val
|
134
|
+
* @param {Boolean} escaped
|
135
|
+
* @param {Boolean} terse
|
136
|
+
* @return {String}
|
137
|
+
*/
|
138
|
+
exports.attr = pug_attr;
|
139
|
+
function pug_attr(key, val, escaped, terse) {
|
140
|
+
if (val === false || val == null || !val && (key === 'class' || key === 'style')) {
|
141
|
+
return '';
|
142
|
+
}
|
143
|
+
if (val === true) {
|
144
|
+
return ' ' + (terse ? key : key + '="' + key + '"');
|
145
|
+
}
|
146
|
+
if (typeof val.toJSON === 'function') {
|
147
|
+
val = val.toJSON();
|
148
|
+
}
|
149
|
+
if (typeof val !== 'string') {
|
150
|
+
val = JSON.stringify(val);
|
151
|
+
if (!escaped && val.indexOf('"') !== -1) {
|
152
|
+
return ' ' + key + '=\'' + val.replace(/'/g, ''') + '\'';
|
153
|
+
}
|
154
|
+
}
|
155
|
+
if (escaped) val = pug_escape(val);
|
156
|
+
return ' ' + key + '="' + val + '"';
|
157
|
+
};
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Render the given attributes object.
|
161
|
+
*
|
162
|
+
* @param {Object} obj
|
163
|
+
* @param {Object} terse whether to use HTML5 terse boolean attributes
|
164
|
+
* @return {String}
|
165
|
+
*/
|
166
|
+
exports.attrs = pug_attrs;
|
167
|
+
function pug_attrs(obj, terse) {
|
168
|
+
var attrs = '';
|
169
|
+
|
170
|
+
for (var key in obj) {
|
171
|
+
if (pug_has_own_property.call(obj, key)) {
|
172
|
+
var val = obj[key];
|
173
|
+
|
174
|
+
if ('class' === key) {
|
175
|
+
val = pug_classes(val);
|
176
|
+
attrs = pug_attr(key, val, false, terse) + attrs;
|
177
|
+
continue;
|
178
|
+
}
|
179
|
+
if ('style' === key) {
|
180
|
+
val = pug_style(val);
|
181
|
+
}
|
182
|
+
attrs += pug_attr(key, val, false, terse);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
186
|
+
return attrs;
|
187
|
+
};
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Escape the given string of `html`.
|
191
|
+
*
|
192
|
+
* @param {String} html
|
193
|
+
* @return {String}
|
194
|
+
* @api private
|
195
|
+
*/
|
196
|
+
|
197
|
+
var pug_match_html = /["&<>]/;
|
198
|
+
exports.escape = pug_escape;
|
199
|
+
function pug_escape(_html) {
|
200
|
+
var html = '' + _html;
|
201
|
+
var regexResult = pug_match_html.exec(html);
|
202
|
+
if (!regexResult) return _html;
|
203
|
+
|
204
|
+
var result = '';
|
205
|
+
var i, lastIndex, escape;
|
206
|
+
for (i = regexResult.index, lastIndex = 0; i < html.length; i++) {
|
207
|
+
switch (html.charCodeAt(i)) {
|
208
|
+
case 34:
|
209
|
+
escape = '"';break;
|
210
|
+
case 38:
|
211
|
+
escape = '&';break;
|
212
|
+
case 60:
|
213
|
+
escape = '<';break;
|
214
|
+
case 62:
|
215
|
+
escape = '>';break;
|
216
|
+
default:
|
217
|
+
continue;
|
218
|
+
}
|
219
|
+
if (lastIndex !== i) result += html.substring(lastIndex, i);
|
220
|
+
lastIndex = i + 1;
|
221
|
+
result += escape;
|
222
|
+
}
|
223
|
+
if (lastIndex !== i) return result + html.substring(lastIndex, i);else return result;
|
224
|
+
};
|
225
|
+
|
226
|
+
/**
|
227
|
+
* Re-throw the given `err` in context to the
|
228
|
+
* the pug in `filename` at the given `lineno`.
|
229
|
+
*
|
230
|
+
* @param {Error} err
|
231
|
+
* @param {String} filename
|
232
|
+
* @param {String} lineno
|
233
|
+
* @param {String} str original source
|
234
|
+
* @api private
|
235
|
+
*/
|
236
|
+
|
237
|
+
exports.rethrow = pug_rethrow;
|
238
|
+
function pug_rethrow(err, filename, lineno, str) {
|
239
|
+
if (!(err instanceof Error)) throw err;
|
240
|
+
if ((typeof window != 'undefined' || !filename) && !str) {
|
241
|
+
err.message += ' on line ' + lineno;
|
242
|
+
throw err;
|
243
|
+
}
|
244
|
+
try {
|
245
|
+
str = str || require('fs').readFileSync(filename, 'utf8');
|
246
|
+
} catch (ex) {
|
247
|
+
pug_rethrow(err, null, lineno);
|
248
|
+
}
|
249
|
+
var context = 3,
|
250
|
+
lines = str.split('\n'),
|
251
|
+
start = Math.max(lineno - context, 0),
|
252
|
+
end = Math.min(lines.length, lineno + context);
|
253
|
+
|
254
|
+
// Error context
|
255
|
+
var context = lines.slice(start, end).map(function (line, i) {
|
256
|
+
var curr = i + start + 1;
|
257
|
+
return (curr == lineno ? ' > ' : ' ') + curr + '| ' + line;
|
258
|
+
}).join('\n');
|
259
|
+
|
260
|
+
// Alter exception message
|
261
|
+
err.path = filename;
|
262
|
+
err.message = (filename || 'Pug') + ':' + lineno + '\n' + context + '\n\n' + err.message;
|
263
|
+
throw err;
|
264
|
+
};
|
265
|
+
|
266
|
+
},{"fs":1}]},{},[2])(2)
|
267
|
+
});
|