jader 0.0.3 → 0.0.4
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.
- data/.gitignore +2 -0
- data/README.md +8 -8
- data/jader.gemspec +2 -1
- data/lib/jader/compiler.rb +53 -24
- data/lib/jader/configuration.rb +9 -0
- data/lib/jader/renderer.rb +11 -0
- data/lib/jader/serialize.rb +28 -9
- data/lib/jader/source.rb +6 -0
- data/lib/jader/template.rb +7 -8
- data/lib/jader/version.rb +1 -1
- data/spec/compiler_spec.rb +5 -3
- data/spec/template_spec.rb +5 -3
- data/vendor/assets/javascripts/jade/jade.js +668 -215
- data/vendor/assets/javascripts/jade/runtime.js +77 -26
- metadata +19 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
jade = (function(exports){
|
3
3
|
/*!
|
4
4
|
* Jade - runtime
|
5
5
|
* Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
|
@@ -29,41 +29,97 @@ if (!Object.keys) {
|
|
29
29
|
}
|
30
30
|
}
|
31
31
|
return arr;
|
32
|
-
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Merge two attribute objects giving precedence
|
37
|
+
* to values in object `b`. Classes are special-cased
|
38
|
+
* allowing for arrays and merging/joining appropriately
|
39
|
+
* resulting in a string.
|
40
|
+
*
|
41
|
+
* @param {Object} a
|
42
|
+
* @param {Object} b
|
43
|
+
* @return {Object} a
|
44
|
+
* @api private
|
45
|
+
*/
|
46
|
+
|
47
|
+
exports.merge = function merge(a, b) {
|
48
|
+
var ac = a['class'];
|
49
|
+
var bc = b['class'];
|
50
|
+
|
51
|
+
if (ac || bc) {
|
52
|
+
ac = ac || [];
|
53
|
+
bc = bc || [];
|
54
|
+
if (!Array.isArray(ac)) ac = [ac];
|
55
|
+
if (!Array.isArray(bc)) bc = [bc];
|
56
|
+
ac = ac.filter(nulls);
|
57
|
+
bc = bc.filter(nulls);
|
58
|
+
a['class'] = ac.concat(bc).join(' ');
|
59
|
+
}
|
60
|
+
|
61
|
+
for (var key in b) {
|
62
|
+
if (key != 'class') {
|
63
|
+
a[key] = b[key];
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
return a;
|
68
|
+
};
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Filter null `val`s.
|
72
|
+
*
|
73
|
+
* @param {Mixed} val
|
74
|
+
* @return {Mixed}
|
75
|
+
* @api private
|
76
|
+
*/
|
77
|
+
|
78
|
+
function nulls(val) {
|
79
|
+
return val != null;
|
33
80
|
}
|
34
81
|
|
35
82
|
/**
|
36
83
|
* Render the given attributes object.
|
37
84
|
*
|
38
85
|
* @param {Object} obj
|
86
|
+
* @param {Object} escaped
|
39
87
|
* @return {String}
|
40
88
|
* @api private
|
41
89
|
*/
|
42
90
|
|
43
|
-
exports.attrs = function attrs(obj){
|
91
|
+
exports.attrs = function attrs(obj, escaped){
|
44
92
|
var buf = []
|
45
93
|
, terse = obj.terse;
|
94
|
+
|
46
95
|
delete obj.terse;
|
47
96
|
var keys = Object.keys(obj)
|
48
97
|
, len = keys.length;
|
98
|
+
|
49
99
|
if (len) {
|
50
100
|
buf.push('');
|
51
101
|
for (var i = 0; i < len; ++i) {
|
52
102
|
var key = keys[i]
|
53
103
|
, val = obj[key];
|
104
|
+
|
54
105
|
if ('boolean' == typeof val || null == val) {
|
55
106
|
if (val) {
|
56
107
|
terse
|
57
108
|
? buf.push(key)
|
58
109
|
: buf.push(key + '="' + key + '"');
|
59
110
|
}
|
111
|
+
} else if (0 == key.indexOf('data') && 'string' != typeof val) {
|
112
|
+
buf.push(key + "='" + JSON.stringify(val) + "'");
|
60
113
|
} else if ('class' == key && Array.isArray(val)) {
|
61
114
|
buf.push(key + '="' + exports.escape(val.join(' ')) + '"');
|
62
|
-
} else {
|
115
|
+
} else if (escaped && escaped[key]) {
|
63
116
|
buf.push(key + '="' + exports.escape(val) + '"');
|
117
|
+
} else {
|
118
|
+
buf.push(key + '="' + val + '"');
|
64
119
|
}
|
65
120
|
}
|
66
121
|
}
|
122
|
+
|
67
123
|
return buf.join(' ');
|
68
124
|
};
|
69
125
|
|
@@ -77,7 +133,7 @@ exports.attrs = function attrs(obj){
|
|
77
133
|
|
78
134
|
exports.escape = function escape(html){
|
79
135
|
return String(html)
|
80
|
-
.replace(/&(
|
136
|
+
.replace(/&(?!(\w+|\#\d+);)/g, '&')
|
81
137
|
.replace(/</g, '<')
|
82
138
|
.replace(/>/g, '>')
|
83
139
|
.replace(/"/g, '"');
|
@@ -96,30 +152,25 @@ exports.escape = function escape(html){
|
|
96
152
|
exports.rethrow = function rethrow(err, filename, lineno){
|
97
153
|
if (!filename) throw err;
|
98
154
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
+ line;
|
114
|
-
}).join('\n') + '\n\n';
|
115
|
-
} catch(failure) {
|
116
|
-
var context = '';
|
117
|
-
}
|
155
|
+
var context = 3
|
156
|
+
, str = require('fs').readFileSync(filename, 'utf8')
|
157
|
+
, lines = str.split('\n')
|
158
|
+
, start = Math.max(lineno - context, 0)
|
159
|
+
, end = Math.min(lines.length, lineno + context);
|
160
|
+
|
161
|
+
// Error context
|
162
|
+
var context = lines.slice(start, end).map(function(line, i){
|
163
|
+
var curr = i + start + 1;
|
164
|
+
return (curr == lineno ? ' > ' : ' ')
|
165
|
+
+ curr
|
166
|
+
+ '| '
|
167
|
+
+ line;
|
168
|
+
}).join('\n');
|
118
169
|
|
119
170
|
// Alter exception message
|
120
171
|
err.path = filename;
|
121
|
-
err.message = (filename || 'Jade') + ':' + lineno
|
122
|
-
+ '\n' + context + err.message;
|
172
|
+
err.message = (filename || 'Jade') + ':' + lineno
|
173
|
+
+ '\n' + context + '\n\n' + err.message;
|
123
174
|
throw err;
|
124
175
|
};
|
125
176
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ cert_chain: []
|
|
13
13
|
date: 2012-08-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: libv8
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
@@ -124,6 +124,22 @@ dependencies:
|
|
124
124
|
- - ! '>='
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: yard
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
type: :development
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
127
143
|
description: Share your Jade views between client and server, eliminate code duplication
|
128
144
|
and make your single-page app SEO friendly
|
129
145
|
email:
|
@@ -276,3 +292,4 @@ test_files:
|
|
276
292
|
- spec/support/global.rb
|
277
293
|
- spec/support/matchers.rb
|
278
294
|
- spec/template_spec.rb
|
295
|
+
has_rdoc:
|