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 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
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 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | function nulls(val) {
|
53 | return val != null && val !== '';
|
54 | }
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
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 |
|
71 |
|
72 |
|
73 |
|
74 |
|
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 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
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 |
|
147 |
|
148 |
|
149 |
|
150 |
|
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 |
|
177 |
|
178 |
|
179 |
|
180 |
|
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 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
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 |
|
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 |
|
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 | }); |
\ | No newline at end of file |