hca 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +1 -0
- data/hca.gemspec +25 -0
- data/lib/hca.rb +4 -0
- data/lib/hca/configuration.rb +24 -0
- data/lib/hca/engine.rb +11 -0
- data/lib/hca/template.rb +51 -0
- data/lib/hca/version.rb +3 -0
- data/vendor/assets/javascripts/hamlcoffee.js +2433 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: db065f6bb4ae1e9648d33dea57da291838b98c4d
|
4
|
+
data.tar.gz: dbfa2cf6bc6c37176bb0bc3115f3cbd6bdb0fca7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4070b9eb4626244c9a399766017105216a33e230f2c784edbb45f5fde54f187c8206523f72457fb68b78065f6f5d6a6b84cec4b98dec108f69abd0641f06eab4
|
7
|
+
data.tar.gz: 9233ce8e115a18e31286d48ae72e57f1c16a414349688f9c0c279083300230457521ac2e7dc51a1bebf5208d601ec9820bc2d71b87470873feb643629f59ad96
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.idea/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Andrei Gladkyi
|
2
|
+
|
3
|
+
MIT License
|
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
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# HCA (HAML-CoffeeScript Assets)
|
2
|
+
|
3
|
+
HCA compiles HAML templates with inline CoffeeScript code into client-side JavaScript template functions that are available in `window.JST` object.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Ruby on Rails 3.1+ is required.
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'hca'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```
|
18
|
+
$ bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
## Configuration
|
22
|
+
|
23
|
+
You can configure HCA by adding an initializer into your `config/initializers` directory. Configuration options are:
|
24
|
+
- `templates_path` - base templates path used for generating correct template keys in `window.JST` object. Default value is `app/assets/javascripts`
|
25
|
+
- `escape_html` - escape special HTML characters. Enabled by default
|
26
|
+
- `custom_html_escape` - the name of the custom HTML escape function
|
27
|
+
- `clean_value` - render empty strings instead of NULL or undefined CoffeeScript values. Enabled by default
|
28
|
+
- `custom_clean_value` - the name of the custom function to clean CoffeeScript values
|
29
|
+
|
30
|
+
### Example
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
Hca.configure do |config|
|
34
|
+
config.custom_html_escape = '_.escape' # using Underscore.js 'escape' function
|
35
|
+
config.custom_clean_value = '$.trim' # using jQuery.trim to clean NULL or undefined CoffeeScript values
|
36
|
+
config.templates_path = 'app/assets/javascripts/templates'
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
* Put HAML templates to your `app/assets/javascripts/...` directory. Give them `.hca` extention.
|
43
|
+
* Add an initializer with correct path to your `.hca` templates
|
44
|
+
* Add templates to the Assets Pipeline
|
45
|
+
|
46
|
+
### Example
|
47
|
+
|
48
|
+
HCA template
|
49
|
+
|
50
|
+
TODO: add an example here
|
51
|
+
|
52
|
+
## Hints
|
53
|
+
|
54
|
+
* Using custom cleanup and escape functions helps reducing the size of the generated JavaScript code.
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
MIT
|
59
|
+
|
60
|
+
HCA internally uses [haml-coffee](https://github.com/netzpirat/haml-coffee) library.
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
1. Fork it (https://github.com/arg/hca/fork)
|
65
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
66
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
67
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
68
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/hca.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hca/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'hca'
|
8
|
+
spec.version = Hca::VERSION
|
9
|
+
spec.authors = ['Andrei Gladkyi']
|
10
|
+
spec.email = ['arg@arglabs.net']
|
11
|
+
spec.summary = %q{Compiles HAML CoffeScript templates into a client-side JavaScript code}
|
12
|
+
spec.homepage = 'https://github.com/arg/hca'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'tilt'
|
21
|
+
spec.add_dependency 'execjs'
|
22
|
+
spec.add_dependency 'coffee-script'
|
23
|
+
spec.add_development_dependency 'bundler'
|
24
|
+
spec.add_development_dependency 'rails', '>= 3.1.0'
|
25
|
+
end
|
data/lib/hca.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Hca
|
2
|
+
OPTIONS = [:escape_html, :clean_value, :custom_html_escape, :custom_clean_value, :templates_path]
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def configure
|
7
|
+
yield(config) if block_given?
|
8
|
+
end
|
9
|
+
|
10
|
+
def config
|
11
|
+
@config ||= get_config
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def get_config
|
17
|
+
Struct.new(*OPTIONS).new.tap do |config|
|
18
|
+
config.escape_html = true
|
19
|
+
config.clean_value = true
|
20
|
+
config.templates_path = 'app/assets/javascripts'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/hca/engine.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module Hca
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
isolate_namespace Hca
|
4
|
+
|
5
|
+
initializer 'hca.environment', after: 'sprockets.environment', group: :all do |app|
|
6
|
+
next unless app.assets
|
7
|
+
require 'hca/template'
|
8
|
+
app.assets.register_engine '.hca', Hca::Template
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/hca/template.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Hca
|
2
|
+
class Template < Tilt::Template
|
3
|
+
self.default_mime_type = 'application/javascript'
|
4
|
+
|
5
|
+
def prepare
|
6
|
+
@data = @data.gsub("'", "\\'").gsub("\n", "\\n")
|
7
|
+
end
|
8
|
+
|
9
|
+
def evaluate(scope, locals, &block)
|
10
|
+
cs_template = self.class.runtime.eval("compile('#{data}', #{config})")
|
11
|
+
js_template = CoffeeScript.compile(cs_template, no_wrap: true)
|
12
|
+
@output ||= wrap_template(js_template)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def wrap_template(template)
|
18
|
+
<<-JST
|
19
|
+
(function() {
|
20
|
+
window.JST || (window.JST = {});
|
21
|
+
window.JST['#{template_name}'] = function(context) {
|
22
|
+
return function() { #{template} }.call(context);
|
23
|
+
};
|
24
|
+
})();
|
25
|
+
JST
|
26
|
+
end
|
27
|
+
|
28
|
+
def config
|
29
|
+
Hca.config.as_json.transform_keys { |key| key.camelize(:lower) }.to_json
|
30
|
+
end
|
31
|
+
|
32
|
+
def template_name
|
33
|
+
path = Pathname.new(file).relative_path_from(Rails.root.join(Hca.config.templates_path))
|
34
|
+
path.to_s.chomp(path.extname)
|
35
|
+
rescue
|
36
|
+
file
|
37
|
+
end
|
38
|
+
|
39
|
+
class << self
|
40
|
+
def runtime
|
41
|
+
@runtime ||= load_runtime
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_runtime
|
45
|
+
path = File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'assets', 'javascripts', '**', '*.js')
|
46
|
+
runtime = Dir[path].map { |file| File.read(file) }
|
47
|
+
ExecJS.compile(runtime.join(' '))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/hca/version.rb
ADDED
@@ -0,0 +1,2433 @@
|
|
1
|
+
/**!
|
2
|
+
* Copyright (c) 2011 9elements, 2011-2013 Michael Kessler
|
3
|
+
*
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
5
|
+
* software and associated documentation files (the 'Software'), to deal in the Software
|
6
|
+
* without restriction, including without limitation the rights to use, copy, modify, merge,
|
7
|
+
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
8
|
+
* to whom the Software is furnished to do so, subject to the following conditions:
|
9
|
+
*
|
10
|
+
* The above copyright notice and this permission notice shall be included in all copies or
|
11
|
+
* substantial portions of the Software.
|
12
|
+
*
|
13
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
14
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
15
|
+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
16
|
+
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
17
|
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
18
|
+
* DEALINGS IN THE SOFTWARE.
|
19
|
+
*/
|
20
|
+
|
21
|
+
var require = function (file, cwd) {
|
22
|
+
var resolved = require.resolve(file, cwd || '/');
|
23
|
+
var mod = require.modules[resolved];
|
24
|
+
if (!mod) throw new Error(
|
25
|
+
'Failed to resolve module ' + file + ', tried ' + resolved
|
26
|
+
);
|
27
|
+
var cached = require.cache[resolved];
|
28
|
+
var res = cached ? cached.exports : mod();
|
29
|
+
return res;
|
30
|
+
};
|
31
|
+
|
32
|
+
require.paths = [];
|
33
|
+
require.modules = {};
|
34
|
+
require.cache = {};
|
35
|
+
require.extensions = [".js", ".coffee", ".json"];
|
36
|
+
|
37
|
+
require._core = {
|
38
|
+
'assert': true,
|
39
|
+
'events': true,
|
40
|
+
'fs': true,
|
41
|
+
'path': true,
|
42
|
+
'vm': true
|
43
|
+
};
|
44
|
+
|
45
|
+
require.resolve = (function () {
|
46
|
+
return function (x, cwd) {
|
47
|
+
if (!cwd) cwd = '/';
|
48
|
+
|
49
|
+
if (require._core[x]) return x;
|
50
|
+
var path = require.modules.path();
|
51
|
+
cwd = path.resolve('/', cwd);
|
52
|
+
var y = cwd || '/';
|
53
|
+
|
54
|
+
if (x.match(/^(?:\.\.?\/|\/)/)) {
|
55
|
+
var m = loadAsFileSync(path.resolve(y, x))
|
56
|
+
|| loadAsDirectorySync(path.resolve(y, x));
|
57
|
+
if (m) return m;
|
58
|
+
}
|
59
|
+
|
60
|
+
var n = loadNodeModulesSync(x, y);
|
61
|
+
if (n) return n;
|
62
|
+
|
63
|
+
throw new Error("Cannot find module '" + x + "'");
|
64
|
+
|
65
|
+
function loadAsFileSync(x) {
|
66
|
+
x = path.normalize(x);
|
67
|
+
if (require.modules[x]) {
|
68
|
+
return x;
|
69
|
+
}
|
70
|
+
|
71
|
+
for (var i = 0; i < require.extensions.length; i++) {
|
72
|
+
var ext = require.extensions[i];
|
73
|
+
if (require.modules[x + ext]) return x + ext;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
function loadAsDirectorySync(x) {
|
78
|
+
x = x.replace(/\/+$/, '');
|
79
|
+
var pkgfile = path.normalize(x + '/package.json');
|
80
|
+
if (require.modules[pkgfile]) {
|
81
|
+
var pkg = require.modules[pkgfile]();
|
82
|
+
var b = pkg.browserify;
|
83
|
+
if (typeof b === 'object' && b.main) {
|
84
|
+
var m = loadAsFileSync(path.resolve(x, b.main));
|
85
|
+
if (m) return m;
|
86
|
+
}
|
87
|
+
else if (typeof b === 'string') {
|
88
|
+
var m = loadAsFileSync(path.resolve(x, b));
|
89
|
+
if (m) return m;
|
90
|
+
}
|
91
|
+
else if (pkg.main) {
|
92
|
+
var m = loadAsFileSync(path.resolve(x, pkg.main));
|
93
|
+
if (m) return m;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
return loadAsFileSync(x + '/index');
|
98
|
+
}
|
99
|
+
|
100
|
+
function loadNodeModulesSync(x, start) {
|
101
|
+
var dirs = nodeModulesPathsSync(start);
|
102
|
+
for (var i = 0; i < dirs.length; i++) {
|
103
|
+
var dir = dirs[i];
|
104
|
+
var m = loadAsFileSync(dir + '/' + x);
|
105
|
+
if (m) return m;
|
106
|
+
var n = loadAsDirectorySync(dir + '/' + x);
|
107
|
+
if (n) return n;
|
108
|
+
}
|
109
|
+
|
110
|
+
var m = loadAsFileSync(x);
|
111
|
+
if (m) return m;
|
112
|
+
}
|
113
|
+
|
114
|
+
function nodeModulesPathsSync(start) {
|
115
|
+
var parts;
|
116
|
+
if (start === '/') parts = [ '' ];
|
117
|
+
else parts = path.normalize(start).split('/');
|
118
|
+
|
119
|
+
var dirs = [];
|
120
|
+
for (var i = parts.length - 1; i >= 0; i--) {
|
121
|
+
if (parts[i] === 'node_modules') continue;
|
122
|
+
var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
|
123
|
+
dirs.push(dir);
|
124
|
+
}
|
125
|
+
|
126
|
+
return dirs;
|
127
|
+
}
|
128
|
+
};
|
129
|
+
})();
|
130
|
+
|
131
|
+
require.alias = function (from, to) {
|
132
|
+
var path = require.modules.path();
|
133
|
+
var res = null;
|
134
|
+
try {
|
135
|
+
res = require.resolve(from + '/package.json', '/');
|
136
|
+
}
|
137
|
+
catch (err) {
|
138
|
+
res = require.resolve(from, '/');
|
139
|
+
}
|
140
|
+
var basedir = path.dirname(res);
|
141
|
+
|
142
|
+
var keys = (Object.keys || function (obj) {
|
143
|
+
var res = [];
|
144
|
+
for (var key in obj) res.push(key);
|
145
|
+
return res;
|
146
|
+
})(require.modules);
|
147
|
+
|
148
|
+
for (var i = 0; i < keys.length; i++) {
|
149
|
+
var key = keys[i];
|
150
|
+
if (key.slice(0, basedir.length + 1) === basedir + '/') {
|
151
|
+
var f = key.slice(basedir.length);
|
152
|
+
require.modules[to + f] = require.modules[basedir + f];
|
153
|
+
}
|
154
|
+
else if (key === basedir) {
|
155
|
+
require.modules[to] = require.modules[basedir];
|
156
|
+
}
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
(function () {
|
161
|
+
var process = {};
|
162
|
+
var global = typeof window !== 'undefined' ? window : {};
|
163
|
+
var definedProcess = false;
|
164
|
+
|
165
|
+
require.define = function (filename, fn) {
|
166
|
+
if (!definedProcess && require.modules.__browserify_process) {
|
167
|
+
process = require.modules.__browserify_process();
|
168
|
+
definedProcess = true;
|
169
|
+
}
|
170
|
+
|
171
|
+
var dirname = require._core[filename]
|
172
|
+
? ''
|
173
|
+
: require.modules.path().dirname(filename)
|
174
|
+
;
|
175
|
+
|
176
|
+
var require_ = function (file) {
|
177
|
+
var requiredModule = require(file, dirname);
|
178
|
+
var cached = require.cache[require.resolve(file, dirname)];
|
179
|
+
|
180
|
+
if (cached && cached.parent === null) {
|
181
|
+
cached.parent = module_;
|
182
|
+
}
|
183
|
+
|
184
|
+
return requiredModule;
|
185
|
+
};
|
186
|
+
require_.resolve = function (name) {
|
187
|
+
return require.resolve(name, dirname);
|
188
|
+
};
|
189
|
+
require_.modules = require.modules;
|
190
|
+
require_.define = require.define;
|
191
|
+
require_.cache = require.cache;
|
192
|
+
var module_ = {
|
193
|
+
id: filename,
|
194
|
+
filename: filename,
|
195
|
+
exports: {},
|
196
|
+
loaded: false,
|
197
|
+
parent: null
|
198
|
+
};
|
199
|
+
|
200
|
+
require.modules[filename] = function () {
|
201
|
+
require.cache[filename] = module_;
|
202
|
+
fn.call(
|
203
|
+
module_.exports,
|
204
|
+
require_,
|
205
|
+
module_,
|
206
|
+
module_.exports,
|
207
|
+
dirname,
|
208
|
+
filename,
|
209
|
+
process,
|
210
|
+
global
|
211
|
+
);
|
212
|
+
module_.loaded = true;
|
213
|
+
return module_.exports;
|
214
|
+
};
|
215
|
+
};
|
216
|
+
})();
|
217
|
+
|
218
|
+
require.define("path", function (require, module, exports, __dirname, __filename, process, global) {
|
219
|
+
function filter(xs, fn) {
|
220
|
+
var res = [];
|
221
|
+
for (var i = 0; i < xs.length; i++) {
|
222
|
+
if (fn(xs[i], i, xs)) res.push(xs[i]);
|
223
|
+
}
|
224
|
+
return res;
|
225
|
+
}
|
226
|
+
|
227
|
+
// resolves . and .. elements in a path array with directory names there
|
228
|
+
// must be no slashes, empty elements, or device names (c:\) in the array
|
229
|
+
// (so also no leading and trailing slashes - it does not distinguish
|
230
|
+
// relative and absolute paths)
|
231
|
+
function normalizeArray(parts, allowAboveRoot) {
|
232
|
+
// if the path tries to go above the root, `up` ends up > 0
|
233
|
+
var up = 0;
|
234
|
+
for (var i = parts.length; i >= 0; i--) {
|
235
|
+
var last = parts[i];
|
236
|
+
if (last == '.') {
|
237
|
+
parts.splice(i, 1);
|
238
|
+
} else if (last === '..') {
|
239
|
+
parts.splice(i, 1);
|
240
|
+
up++;
|
241
|
+
} else if (up) {
|
242
|
+
parts.splice(i, 1);
|
243
|
+
up--;
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
// if the path is allowed to go above the root, restore leading ..s
|
248
|
+
if (allowAboveRoot) {
|
249
|
+
for (; up--; up) {
|
250
|
+
parts.unshift('..');
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
return parts;
|
255
|
+
}
|
256
|
+
|
257
|
+
// Regex to split a filename into [*, dir, basename, ext]
|
258
|
+
// posix version
|
259
|
+
var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
|
260
|
+
|
261
|
+
// path.resolve([from ...], to)
|
262
|
+
// posix version
|
263
|
+
exports.resolve = function () {
|
264
|
+
var resolvedPath = '',
|
265
|
+
resolvedAbsolute = false;
|
266
|
+
|
267
|
+
for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
|
268
|
+
var path = (i >= 0)
|
269
|
+
? arguments[i]
|
270
|
+
: process.cwd();
|
271
|
+
|
272
|
+
// Skip empty and invalid entries
|
273
|
+
if (typeof path !== 'string' || !path) {
|
274
|
+
continue;
|
275
|
+
}
|
276
|
+
|
277
|
+
resolvedPath = path + '/' + resolvedPath;
|
278
|
+
resolvedAbsolute = path.charAt(0) === '/';
|
279
|
+
}
|
280
|
+
|
281
|
+
// At this point the path should be resolved to a full absolute path, but
|
282
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
283
|
+
|
284
|
+
// Normalize the path
|
285
|
+
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function (p) {
|
286
|
+
return !!p;
|
287
|
+
}), !resolvedAbsolute).join('/');
|
288
|
+
|
289
|
+
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
290
|
+
};
|
291
|
+
|
292
|
+
// path.normalize(path)
|
293
|
+
// posix version
|
294
|
+
exports.normalize = function (path) {
|
295
|
+
var isAbsolute = path.charAt(0) === '/',
|
296
|
+
trailingSlash = path.slice(-1) === '/';
|
297
|
+
|
298
|
+
// Normalize the path
|
299
|
+
path = normalizeArray(filter(path.split('/'), function (p) {
|
300
|
+
return !!p;
|
301
|
+
}), !isAbsolute).join('/');
|
302
|
+
|
303
|
+
if (!path && !isAbsolute) {
|
304
|
+
path = '.';
|
305
|
+
}
|
306
|
+
if (path && trailingSlash) {
|
307
|
+
path += '/';
|
308
|
+
}
|
309
|
+
|
310
|
+
return (isAbsolute ? '/' : '') + path;
|
311
|
+
};
|
312
|
+
|
313
|
+
// posix version
|
314
|
+
exports.join = function () {
|
315
|
+
var paths = Array.prototype.slice.call(arguments, 0);
|
316
|
+
return exports.normalize(filter(paths, function (p, index) {
|
317
|
+
return p && typeof p === 'string';
|
318
|
+
}).join('/'));
|
319
|
+
};
|
320
|
+
|
321
|
+
exports.dirname = function (path) {
|
322
|
+
var dir = splitPathRe.exec(path)[1] || '';
|
323
|
+
var isWindows = false;
|
324
|
+
if (!dir) {
|
325
|
+
// No dirname
|
326
|
+
return '.';
|
327
|
+
} else if (dir.length === 1 ||
|
328
|
+
(isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
|
329
|
+
// It is just a slash or a drive letter with a slash
|
330
|
+
return dir;
|
331
|
+
} else {
|
332
|
+
// It is a full dirname, strip trailing slash
|
333
|
+
return dir.substring(0, dir.length - 1);
|
334
|
+
}
|
335
|
+
};
|
336
|
+
|
337
|
+
exports.basename = function (path, ext) {
|
338
|
+
var f = splitPathRe.exec(path)[2] || '';
|
339
|
+
// TODO: make this comparison case-insensitive on windows?
|
340
|
+
if (ext && f.substr(-1 * ext.length) === ext) {
|
341
|
+
f = f.substr(0, f.length - ext.length);
|
342
|
+
}
|
343
|
+
return f;
|
344
|
+
};
|
345
|
+
|
346
|
+
exports.extname = function (path) {
|
347
|
+
return splitPathRe.exec(path)[3] || '';
|
348
|
+
};
|
349
|
+
|
350
|
+
exports.relative = function (from, to) {
|
351
|
+
from = exports.resolve(from).substr(1);
|
352
|
+
to = exports.resolve(to).substr(1);
|
353
|
+
|
354
|
+
function trim(arr) {
|
355
|
+
var start = 0;
|
356
|
+
for (; start < arr.length; start++) {
|
357
|
+
if (arr[start] !== '') break;
|
358
|
+
}
|
359
|
+
|
360
|
+
var end = arr.length - 1;
|
361
|
+
for (; end >= 0; end--) {
|
362
|
+
if (arr[end] !== '') break;
|
363
|
+
}
|
364
|
+
|
365
|
+
if (start > end) return [];
|
366
|
+
return arr.slice(start, end - start + 1);
|
367
|
+
}
|
368
|
+
|
369
|
+
var fromParts = trim(from.split('/'));
|
370
|
+
var toParts = trim(to.split('/'));
|
371
|
+
|
372
|
+
var length = Math.min(fromParts.length, toParts.length);
|
373
|
+
var samePartsLength = length;
|
374
|
+
for (var i = 0; i < length; i++) {
|
375
|
+
if (fromParts[i] !== toParts[i]) {
|
376
|
+
samePartsLength = i;
|
377
|
+
break;
|
378
|
+
}
|
379
|
+
}
|
380
|
+
|
381
|
+
var outputParts = [];
|
382
|
+
for (var i = samePartsLength; i < fromParts.length; i++) {
|
383
|
+
outputParts.push('..');
|
384
|
+
}
|
385
|
+
|
386
|
+
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
387
|
+
|
388
|
+
return outputParts.join('/');
|
389
|
+
};
|
390
|
+
|
391
|
+
});
|
392
|
+
|
393
|
+
require.define("__browserify_process", function (require, module, exports, __dirname, __filename, process, global) {
|
394
|
+
var process = module.exports = {};
|
395
|
+
|
396
|
+
process.nextTick = (function () {
|
397
|
+
var canSetImmediate = typeof window !== 'undefined'
|
398
|
+
&& window.setImmediate;
|
399
|
+
var canPost = typeof window !== 'undefined'
|
400
|
+
&& window.postMessage && window.addEventListener
|
401
|
+
;
|
402
|
+
|
403
|
+
if (canSetImmediate) {
|
404
|
+
return function (f) {
|
405
|
+
return window.setImmediate(f)
|
406
|
+
};
|
407
|
+
}
|
408
|
+
|
409
|
+
if (canPost) {
|
410
|
+
var queue = [];
|
411
|
+
window.addEventListener('message', function (ev) {
|
412
|
+
if (ev.source === window && ev.data === 'browserify-tick') {
|
413
|
+
ev.stopPropagation();
|
414
|
+
if (queue.length > 0) {
|
415
|
+
var fn = queue.shift();
|
416
|
+
fn();
|
417
|
+
}
|
418
|
+
}
|
419
|
+
}, true);
|
420
|
+
|
421
|
+
return function nextTick(fn) {
|
422
|
+
queue.push(fn);
|
423
|
+
window.postMessage('browserify-tick', '*');
|
424
|
+
};
|
425
|
+
}
|
426
|
+
|
427
|
+
return function nextTick(fn) {
|
428
|
+
setTimeout(fn, 0);
|
429
|
+
};
|
430
|
+
})();
|
431
|
+
|
432
|
+
process.title = 'browser';
|
433
|
+
process.browser = true;
|
434
|
+
process.env = {};
|
435
|
+
process.argv = [];
|
436
|
+
|
437
|
+
process.binding = function (name) {
|
438
|
+
if (name === 'evals') return (require)('vm')
|
439
|
+
else throw new Error('No such module. (Possibly not yet loaded)')
|
440
|
+
};
|
441
|
+
|
442
|
+
(function () {
|
443
|
+
var cwd = '/';
|
444
|
+
var path;
|
445
|
+
process.cwd = function () {
|
446
|
+
return cwd
|
447
|
+
};
|
448
|
+
process.chdir = function (dir) {
|
449
|
+
if (!path) path = require('path');
|
450
|
+
cwd = path.resolve(dir, cwd);
|
451
|
+
};
|
452
|
+
})();
|
453
|
+
|
454
|
+
});
|
455
|
+
|
456
|
+
require.define("/haml-coffee.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
457
|
+
(function () {
|
458
|
+
var Code, Comment, Directive, Filter, Haml, HamlCoffee, Node, Text, indent, whitespace;
|
459
|
+
|
460
|
+
Node = require('./nodes/node');
|
461
|
+
|
462
|
+
Text = require('./nodes/text');
|
463
|
+
|
464
|
+
Haml = require('./nodes/haml');
|
465
|
+
|
466
|
+
Code = require('./nodes/code');
|
467
|
+
|
468
|
+
Comment = require('./nodes/comment');
|
469
|
+
|
470
|
+
Filter = require('./nodes/filter');
|
471
|
+
|
472
|
+
Directive = require('./nodes/directive');
|
473
|
+
|
474
|
+
whitespace = require('./util/text').whitespace;
|
475
|
+
|
476
|
+
indent = require('./util/text').indent;
|
477
|
+
|
478
|
+
module.exports = HamlCoffee = (function () {
|
479
|
+
HamlCoffee.VERSION = '1.14.1';
|
480
|
+
|
481
|
+
function HamlCoffee(options) {
|
482
|
+
var segment, segments, _base, _base1, _base10, _base11, _base12, _base13, _base2, _base3, _base4, _base5, _base6, _base7, _base8, _base9, _i, _len;
|
483
|
+
this.options = options != null ? options : {};
|
484
|
+
if ((_base = this.options).placement == null) {
|
485
|
+
_base.placement = 'global';
|
486
|
+
}
|
487
|
+
if ((_base1 = this.options).dependencies == null) {
|
488
|
+
_base1.dependencies = {
|
489
|
+
hc: 'hamlcoffee'
|
490
|
+
};
|
491
|
+
}
|
492
|
+
if ((_base2 = this.options).escapeHtml == null) {
|
493
|
+
_base2.escapeHtml = true;
|
494
|
+
}
|
495
|
+
if ((_base3 = this.options).escapeAttributes == null) {
|
496
|
+
_base3.escapeAttributes = true;
|
497
|
+
}
|
498
|
+
if ((_base4 = this.options).cleanValue == null) {
|
499
|
+
_base4.cleanValue = true;
|
500
|
+
}
|
501
|
+
if ((_base5 = this.options).uglify == null) {
|
502
|
+
_base5.uglify = false;
|
503
|
+
}
|
504
|
+
if ((_base6 = this.options).basename == null) {
|
505
|
+
_base6.basename = false;
|
506
|
+
}
|
507
|
+
if ((_base7 = this.options).extendScope == null) {
|
508
|
+
_base7.extendScope = false;
|
509
|
+
}
|
510
|
+
if ((_base8 = this.options).format == null) {
|
511
|
+
_base8.format = 'html5';
|
512
|
+
}
|
513
|
+
if ((_base9 = this.options).hyphenateDataAttrs == null) {
|
514
|
+
_base9.hyphenateDataAttrs = true;
|
515
|
+
}
|
516
|
+
if ((_base10 = this.options).preserveTags == null) {
|
517
|
+
_base10.preserveTags = 'pre,textarea';
|
518
|
+
}
|
519
|
+
if ((_base11 = this.options).selfCloseTags == null) {
|
520
|
+
_base11.selfCloseTags = 'meta,img,link,br,hr,input,area,param,col,base';
|
521
|
+
}
|
522
|
+
if (this.options.placement === 'global') {
|
523
|
+
if ((_base12 = this.options).name == null) {
|
524
|
+
_base12.name = 'test';
|
525
|
+
}
|
526
|
+
if ((_base13 = this.options).namespace == null) {
|
527
|
+
_base13.namespace = 'window.HAML';
|
528
|
+
}
|
529
|
+
segments =
|
530
|
+
("" + this.options.namespace + "." + this.options.name).replace(/(\s|-)+/g, '_').split(/\./);
|
531
|
+
this.options.name = this.options.basename ? segments.pop().split(/\/|\\/).pop() : segments.pop();
|
532
|
+
this.options.namespace = segments.shift();
|
533
|
+
this.intro = '';
|
534
|
+
if (segments.length !== 0) {
|
535
|
+
for (_i = 0, _len = segments.length; _i < _len; _i++) {
|
536
|
+
segment = segments[_i];
|
537
|
+
this.options.namespace += "." + segment;
|
538
|
+
this.intro += "" + this.options.namespace + " ?= {}\n";
|
539
|
+
}
|
540
|
+
} else {
|
541
|
+
this.intro += "" + this.options.namespace + " ?= {}\n";
|
542
|
+
}
|
543
|
+
}
|
544
|
+
}
|
545
|
+
|
546
|
+
HamlCoffee.prototype.indentChanged = function () {
|
547
|
+
return this.currentIndent !== this.previousIndent;
|
548
|
+
};
|
549
|
+
|
550
|
+
HamlCoffee.prototype.isIndent = function () {
|
551
|
+
return this.currentIndent > this.previousIndent;
|
552
|
+
};
|
553
|
+
|
554
|
+
HamlCoffee.prototype.updateTabSize = function () {
|
555
|
+
if (this.tabSize === 0) {
|
556
|
+
return this.tabSize = this.currentIndent - this.previousIndent;
|
557
|
+
}
|
558
|
+
};
|
559
|
+
|
560
|
+
HamlCoffee.prototype.updateBlockLevel = function () {
|
561
|
+
this.currentBlockLevel = this.currentIndent / this.tabSize;
|
562
|
+
if (!this.node.isCommented()) {
|
563
|
+
if (this.currentBlockLevel - Math.floor(this.currentBlockLevel) > 0) {
|
564
|
+
throw "Indentation error in line " + this.lineNumber;
|
565
|
+
}
|
566
|
+
if ((this.currentIndent - this.previousIndent) / this.tabSize > 1) {
|
567
|
+
throw "Block level too deep in line " + this.lineNumber;
|
568
|
+
}
|
569
|
+
}
|
570
|
+
return this.delta = this.previousBlockLevel - this.currentBlockLevel;
|
571
|
+
};
|
572
|
+
|
573
|
+
HamlCoffee.prototype.updateCodeBlockLevel = function (node) {
|
574
|
+
if (node instanceof Code) {
|
575
|
+
return this.currentCodeBlockLevel = node.codeBlockLevel + 1;
|
576
|
+
} else {
|
577
|
+
return this.currentCodeBlockLevel = node.codeBlockLevel;
|
578
|
+
}
|
579
|
+
};
|
580
|
+
|
581
|
+
HamlCoffee.prototype.updateParent = function () {
|
582
|
+
if (this.isIndent()) {
|
583
|
+
return this.pushParent();
|
584
|
+
} else {
|
585
|
+
return this.popParent();
|
586
|
+
}
|
587
|
+
};
|
588
|
+
|
589
|
+
HamlCoffee.prototype.pushParent = function () {
|
590
|
+
this.stack.push(this.parentNode);
|
591
|
+
return this.parentNode = this.node;
|
592
|
+
};
|
593
|
+
|
594
|
+
HamlCoffee.prototype.popParent = function () {
|
595
|
+
var i, _i, _ref, _results;
|
596
|
+
_results = [];
|
597
|
+
for (i = _i = 0, _ref = this.delta - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i =
|
598
|
+
0 <= _ref ? ++_i : --_i) {
|
599
|
+
_results.push(this.parentNode = this.stack.pop());
|
600
|
+
}
|
601
|
+
return _results;
|
602
|
+
};
|
603
|
+
|
604
|
+
HamlCoffee.prototype.getNodeOptions = function (override) {
|
605
|
+
if (override == null) {
|
606
|
+
override = {};
|
607
|
+
}
|
608
|
+
return {
|
609
|
+
parentNode: override.parentNode || this.parentNode,
|
610
|
+
blockLevel: override.blockLevel || this.currentBlockLevel,
|
611
|
+
codeBlockLevel: override.codeBlockLevel || this.currentCodeBlockLevel,
|
612
|
+
escapeHtml: override.escapeHtml || this.options.escapeHtml,
|
613
|
+
escapeAttributes: override.escapeAttributes || this.options.escapeAttributes,
|
614
|
+
cleanValue: override.cleanValue || this.options.cleanValue,
|
615
|
+
format: override.format || this.options.format,
|
616
|
+
hyphenateDataAttrs: override.hyphenateDataAttrs || this.options.format,
|
617
|
+
preserveTags: override.preserveTags || this.options.preserveTags,
|
618
|
+
selfCloseTags: override.selfCloseTags || this.options.selfCloseTags,
|
619
|
+
uglify: override.uglify || this.options.uglify,
|
620
|
+
placement: override.placement || this.options.placement,
|
621
|
+
namespace: override.namespace || this.options.namespace,
|
622
|
+
name: override.name || this.options.name
|
623
|
+
};
|
624
|
+
};
|
625
|
+
|
626
|
+
HamlCoffee.prototype.nodeFactory = function (expression) {
|
627
|
+
var node, options, _ref;
|
628
|
+
if (expression == null) {
|
629
|
+
expression = '';
|
630
|
+
}
|
631
|
+
options = this.getNodeOptions();
|
632
|
+
if (expression.match(/^:(escaped|preserve|css|javascript|plain|cdata|coffeescript)/)) {
|
633
|
+
node = new Filter(expression, options);
|
634
|
+
} else if (expression.match(/^(\/|-#)(.*)/)) {
|
635
|
+
node = new Comment(expression, options);
|
636
|
+
} else if (expression.match(/^(-#|-|=|!=|\&=|~)\s*(.*)/)) {
|
637
|
+
node = new Code(expression, options);
|
638
|
+
} else if (expression.match(/^(%|#[^{]|\.|\!)(.*)/)) {
|
639
|
+
node = new Haml(expression, options);
|
640
|
+
} else if (expression.match(/^\+(.*)/)) {
|
641
|
+
node = new Directive(expression, options);
|
642
|
+
} else {
|
643
|
+
node = new Text(expression, options);
|
644
|
+
}
|
645
|
+
if ((_ref = options.parentNode) != null) {
|
646
|
+
_ref.addChild(node);
|
647
|
+
}
|
648
|
+
return node;
|
649
|
+
};
|
650
|
+
|
651
|
+
HamlCoffee.prototype.parse = function (source) {
|
652
|
+
var attributes, expression, line, lines, range, result, tabsize, text, ws, _i, _j, _len, _ref, _ref1, _results;
|
653
|
+
if (source == null) {
|
654
|
+
source = '';
|
655
|
+
}
|
656
|
+
this.lineNumber =
|
657
|
+
this.previousIndent = this.tabSize = this.currentBlockLevel = this.previousBlockLevel = 0;
|
658
|
+
this.currentCodeBlockLevel = this.previousCodeBlockLevel = 0;
|
659
|
+
this.node = null;
|
660
|
+
this.stack = [];
|
661
|
+
this.root = this.parentNode = new Node('', this.getNodeOptions());
|
662
|
+
lines = source.replace(/\r/g, '').split("\n");
|
663
|
+
while ((line = lines.shift()) !== void 0) {
|
664
|
+
if ((this.node instanceof Filter) && !this.exitFilter) {
|
665
|
+
if (/^(\s)*$/.test(line)) {
|
666
|
+
this.node.addChild(new Text('', this.getNodeOptions({
|
667
|
+
parentNode: this.node
|
668
|
+
})));
|
669
|
+
} else {
|
670
|
+
result = line.match(/^(\s*)(.*)/);
|
671
|
+
ws = result[1];
|
672
|
+
expression = result[2];
|
673
|
+
if (this.node.blockLevel >= (ws.length / 2)) {
|
674
|
+
this.exitFilter = true;
|
675
|
+
lines.unshift(line);
|
676
|
+
continue;
|
677
|
+
}
|
678
|
+
range = this.tabSize > 2 ? (function () {
|
679
|
+
_results = [];
|
680
|
+
for (var _i = _ref = this.tabSize; _ref <= 1 ? _i <= 1 : _i >= 1; _ref <= 1 ? _i++ :
|
681
|
+
_i--) {
|
682
|
+
_results.push(_i);
|
683
|
+
}
|
684
|
+
return _results;
|
685
|
+
}).apply(this) : [2, 1];
|
686
|
+
for (_j = 0, _len = range.length; _j < _len; _j++) {
|
687
|
+
tabsize = range[_j];
|
688
|
+
text = line.match(RegExp("^\\s{" + ((this.node.blockLevel * tabsize) + tabsize) +
|
689
|
+
"}(.*)"));
|
690
|
+
if (text) {
|
691
|
+
this.node.addChild(new Text(text[1], this.getNodeOptions({
|
692
|
+
parentNode: this.node
|
693
|
+
})));
|
694
|
+
break;
|
695
|
+
}
|
696
|
+
}
|
697
|
+
}
|
698
|
+
} else {
|
699
|
+
this.exitFilter = false;
|
700
|
+
result = line.match(/^(\s*)(.*)/);
|
701
|
+
ws = result[1];
|
702
|
+
expression = result[2];
|
703
|
+
this.currentIndent = ws.length;
|
704
|
+
if (/^\s*$/.test(line)) {
|
705
|
+
continue;
|
706
|
+
}
|
707
|
+
while (/^[%.#].*[{(]/.test(expression) &&
|
708
|
+
RegExp("^\\s{" + (this.previousIndent + (this.tabSize || 2)) + "}").test(lines[0]) &&
|
709
|
+
!/^(\s*)[-=&!~.%#</]/.test(lines[0]) &&
|
710
|
+
/([-\w]+[\w:-]*\w?)\s*=|('\w+[\w:-]*\w?')\s*=|("\w+[\w:-]*\w?")\s*=|(\w+[\w:-]*\w?):|('[-\w]+[\w:-]*\w?'):|("[-\w]+[\w:-]*\w?"):|:(\w+[\w:-]*\w?)\s*=>|:?'([-\w]+[\w:-]*\w?)'\s*=>|:?"([-\w]+[\w:-]*\w?)"\s*=>/.test(lines[0]) &&
|
711
|
+
!/;\s*$/.test(lines[0])) {
|
712
|
+
attributes = lines.shift();
|
713
|
+
expression = expression.replace(/(\s)+\|\s*$/, '');
|
714
|
+
expression += ' ' + attributes.match(/^\s*(.*?)(\s+\|\s*)?$/)[1];
|
715
|
+
this.lineNumber++;
|
716
|
+
}
|
717
|
+
while (/^-#/.test(expression) &&
|
718
|
+
RegExp("^\\s{" + (this.currentIndent + (this.tabSize || 2)) + "}").test(lines[0]) &&
|
719
|
+
lines.length > 0) {
|
720
|
+
lines.shift();
|
721
|
+
this.lineNumber++;
|
722
|
+
}
|
723
|
+
if (expression.match(/(\s)+\|\s*$/)) {
|
724
|
+
expression = expression.replace(/(\s)+\|\s*$/, ' ');
|
725
|
+
while ((_ref1 = lines[0]) != null ? _ref1.match(/(\s)+\|$/) : void 0) {
|
726
|
+
expression += lines.shift().match(/^(\s*)(.*)/)[2].replace(/(\s)+\|\s*$/, '');
|
727
|
+
this.lineNumber++;
|
728
|
+
}
|
729
|
+
}
|
730
|
+
if (this.indentChanged()) {
|
731
|
+
this.updateTabSize();
|
732
|
+
this.updateBlockLevel();
|
733
|
+
this.updateParent();
|
734
|
+
this.updateCodeBlockLevel(this.parentNode);
|
735
|
+
}
|
736
|
+
this.node = this.nodeFactory(expression);
|
737
|
+
this.previousBlockLevel = this.currentBlockLevel;
|
738
|
+
this.previousIndent = this.currentIndent;
|
739
|
+
}
|
740
|
+
this.lineNumber++;
|
741
|
+
}
|
742
|
+
return this.evaluate(this.root);
|
743
|
+
};
|
744
|
+
|
745
|
+
HamlCoffee.prototype.evaluate = function (node) {
|
746
|
+
var child, _i, _len, _ref;
|
747
|
+
_ref = node.children;
|
748
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
749
|
+
child = _ref[_i];
|
750
|
+
this.evaluate(child);
|
751
|
+
}
|
752
|
+
return node.evaluate();
|
753
|
+
};
|
754
|
+
|
755
|
+
HamlCoffee.prototype.render = function () {
|
756
|
+
switch (this.options.placement) {
|
757
|
+
case 'amd':
|
758
|
+
return this.renderAmd();
|
759
|
+
case 'standalone':
|
760
|
+
return this.renderStandalone();
|
761
|
+
default:
|
762
|
+
return this.renderGlobal();
|
763
|
+
}
|
764
|
+
};
|
765
|
+
|
766
|
+
HamlCoffee.prototype.renderStandalone = function () {
|
767
|
+
var template;
|
768
|
+
return template =
|
769
|
+
"return (context) ->\n (->\n" + (indent(this.precompile(), 2)) + "\n ).call(context)";
|
770
|
+
};
|
771
|
+
|
772
|
+
HamlCoffee.prototype.renderAmd = function () {
|
773
|
+
var m, module, modules, param, params, template, _ref, _ref1;
|
774
|
+
if (/^hamlcoffee/.test(this.options.dependencies['hc'])) {
|
775
|
+
this.options.customHtmlEscape = 'hc.escape';
|
776
|
+
this.options.customCleanValue = 'hc.cleanValue';
|
777
|
+
this.options.customPreserve = 'hc.preserve';
|
778
|
+
this.options.customFindAndPreserve = 'hc.findAndPreserve';
|
779
|
+
this.options.customSurround = 'hc.surround';
|
780
|
+
this.options.customSucceed = 'hc.succeed';
|
781
|
+
this.options.customPrecede = 'hc.precede';
|
782
|
+
this.options.customReference = 'hc.reference';
|
783
|
+
}
|
784
|
+
modules = [];
|
785
|
+
params = [];
|
786
|
+
_ref = this.options.dependencies;
|
787
|
+
for (param in _ref) {
|
788
|
+
module = _ref[param];
|
789
|
+
modules.push(module);
|
790
|
+
params.push(param);
|
791
|
+
}
|
792
|
+
if (this.options.extendScope) {
|
793
|
+
template = " `with (context || {}) {`\n" + (indent(this.precompile(), 1)) + "\n`}`";
|
794
|
+
} else {
|
795
|
+
template = this.precompile();
|
796
|
+
}
|
797
|
+
_ref1 = this.findDependencies(template);
|
798
|
+
for (param in _ref1) {
|
799
|
+
module = _ref1[param];
|
800
|
+
modules.push(module);
|
801
|
+
params.push(param);
|
802
|
+
}
|
803
|
+
if (modules.length !== 0) {
|
804
|
+
modules = (function () {
|
805
|
+
var _i, _len, _results;
|
806
|
+
_results = [];
|
807
|
+
for (_i = 0, _len = modules.length; _i < _len; _i++) {
|
808
|
+
m = modules[_i];
|
809
|
+
_results.push("'" + m + "'");
|
810
|
+
}
|
811
|
+
return _results;
|
812
|
+
})();
|
813
|
+
modules = "[" + modules + "], (" + (params.join(', ')) + ")";
|
814
|
+
} else {
|
815
|
+
modules = '';
|
816
|
+
}
|
817
|
+
return "define " + modules + " ->\n (context) ->\n render = ->\n \n" + (indent(template, 4)) +
|
818
|
+
"\n render.call(context)";
|
819
|
+
};
|
820
|
+
|
821
|
+
HamlCoffee.prototype.renderGlobal = function () {
|
822
|
+
var template;
|
823
|
+
template = this.intro;
|
824
|
+
if (this.options.extendScope) {
|
825
|
+
template += "" + this.options.namespace + "['" + this.options.name + "'] = (context) -> ( ->\n";
|
826
|
+
template += " `with (context || {}) {`\n";
|
827
|
+
template += "" + (indent(this.precompile(), 1));
|
828
|
+
template += "`}`\n";
|
829
|
+
template += ").call(context)";
|
830
|
+
} else {
|
831
|
+
template += "" + this.options.namespace + "['" + this.options.name + "'] = (context) -> ( ->\n";
|
832
|
+
template += "" + (indent(this.precompile(), 1));
|
833
|
+
template += ").call(context)";
|
834
|
+
}
|
835
|
+
return template;
|
836
|
+
};
|
837
|
+
|
838
|
+
HamlCoffee.prototype.precompile = function () {
|
839
|
+
var code, fn;
|
840
|
+
fn = '';
|
841
|
+
code = this.createCode();
|
842
|
+
if (code.indexOf('$e') !== -1) {
|
843
|
+
if (this.options.customHtmlEscape) {
|
844
|
+
fn += "$e = " + this.options.customHtmlEscape + "\n";
|
845
|
+
} else {
|
846
|
+
fn +=
|
847
|
+
"$e = (text, escape) ->\n \"\#{ text }\"\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\'/g, ''')\n .replace(/\\//g, '/')\n .replace(/\"/g, '"')\n";
|
848
|
+
}
|
849
|
+
}
|
850
|
+
if (code.indexOf('$c') !== -1) {
|
851
|
+
if (this.options.customCleanValue) {
|
852
|
+
fn += "$c = " + this.options.customCleanValue + "\n";
|
853
|
+
} else {
|
854
|
+
fn += "$c = (text) ->\n";
|
855
|
+
fn += " switch text\n";
|
856
|
+
fn += " when null, undefined then ''\n";
|
857
|
+
fn += " when true, false then '\u0093' + text\n";
|
858
|
+
fn += " else text\n";
|
859
|
+
}
|
860
|
+
}
|
861
|
+
if (code.indexOf('$p') !== -1 || code.indexOf('$fp') !== -1) {
|
862
|
+
if (this.options.customPreserve) {
|
863
|
+
fn += "$p = " + this.options.customPreserve + "\n";
|
864
|
+
} else {
|
865
|
+
fn += "$p = (text) -> text.replace /\\n/g, '
'\n";
|
866
|
+
}
|
867
|
+
}
|
868
|
+
if (code.indexOf('$fp') !== -1) {
|
869
|
+
if (this.options.customFindAndPreserve) {
|
870
|
+
fn += "$fp = " + this.options.customFindAndPreserve + "\n";
|
871
|
+
} else {
|
872
|
+
fn += "$fp = (text) ->\n text.replace /<(" + (this.options.preserveTags.split(',').join('|')) +
|
873
|
+
")>([^]*?)<\\/\\1>/g, (str, tag, content) ->\n \"<\#{ tag }>\#{ $p content }</\#{ tag }>\"\n";
|
874
|
+
}
|
875
|
+
}
|
876
|
+
if (code.indexOf('surround') !== -1) {
|
877
|
+
if (this.options.customSurround) {
|
878
|
+
fn += "surround = (start, end, fn) => " + this.options.customSurround +
|
879
|
+
".call(@, start, end, fn)\n";
|
880
|
+
} else {
|
881
|
+
fn += "surround = (start, end, fn) => start + fn.call(@)?.replace(/^\\s+|\\s+$/g, '') + end\n";
|
882
|
+
}
|
883
|
+
}
|
884
|
+
if (code.indexOf('succeed') !== -1) {
|
885
|
+
if (this.options.customSucceed) {
|
886
|
+
fn += "succeed = (start, end, fn) => " + this.options.customSucceed +
|
887
|
+
".call(@, start, end, fn)\n";
|
888
|
+
} else {
|
889
|
+
fn += "succeed = (end, fn) => fn.call(@)?.replace(/\s+$/g, '') + end\n";
|
890
|
+
}
|
891
|
+
}
|
892
|
+
if (code.indexOf('precede') !== -1) {
|
893
|
+
if (this.options.customPrecede) {
|
894
|
+
fn += "precede = (start, end, fn) => " + this.options.customPrecede +
|
895
|
+
".call(@, start, end, fn)\n";
|
896
|
+
} else {
|
897
|
+
fn += "precede = (start, fn) => start + fn.call(@)?.replace(/^\s+/g, '')\n";
|
898
|
+
}
|
899
|
+
}
|
900
|
+
if (code.indexOf('$r') !== -1) {
|
901
|
+
if (this.options.customReference) {
|
902
|
+
fn += "$r = " + this.options.customReference + "\n";
|
903
|
+
} else {
|
904
|
+
fn +=
|
905
|
+
"$r = (object, prefix) ->\n name = if prefix then prefix + '_' else ''\n\n if typeof(object.hamlObjectRef) is 'function'\n name += object.hamlObjectRef()\n else\n name += (object.constructor?.name || 'object').replace(/\W+/g, '_').replace(/([a-z\d])([A-Z])/g, '$1_$2').toLowerCase()\n\n id = if typeof(object.to_key) is 'function'\n object.to_key()\n else if typeof(object.id) is 'function'\n object.id()\n else if object.id\n object.id\n else\n object\n\n result = \"class='\#{ name }'\"\n result += \" id='\#{ name }_\#{ id }'\" if id\n";
|
906
|
+
}
|
907
|
+
}
|
908
|
+
fn += "$o = []\n";
|
909
|
+
fn += "" + code + "\n";
|
910
|
+
return fn +=
|
911
|
+
"return $o.join(\"\\n\")" + (this.convertBooleans(code)) + (this.removeEmptyIDAndClass(code)) +
|
912
|
+
(this.cleanupWhitespace(code)) + "\n";
|
913
|
+
};
|
914
|
+
|
915
|
+
HamlCoffee.prototype.createCode = function () {
|
916
|
+
var child, code, line, processors, _i, _j, _len, _len1, _ref, _ref1;
|
917
|
+
code = [];
|
918
|
+
this.lines = [];
|
919
|
+
_ref = this.root.children;
|
920
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
921
|
+
child = _ref[_i];
|
922
|
+
this.lines = this.lines.concat(child.render());
|
923
|
+
}
|
924
|
+
this.lines = this.combineText(this.lines);
|
925
|
+
this.blockLevel = 0;
|
926
|
+
_ref1 = this.lines;
|
927
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
928
|
+
line = _ref1[_j];
|
929
|
+
if (line !== null) {
|
930
|
+
switch (line.type) {
|
931
|
+
case 'text':
|
932
|
+
code.push("" + (whitespace(line.cw)) + (this.getBuffer(this.blockLevel)) + ".push \"" +
|
933
|
+
(whitespace(line.hw)) + line.text + "\"");
|
934
|
+
break;
|
935
|
+
case 'run':
|
936
|
+
if (line.block !== 'end') {
|
937
|
+
code.push("" + (whitespace(line.cw)) + line.code);
|
938
|
+
} else {
|
939
|
+
code.push("" + (whitespace(line.cw)) +
|
940
|
+
(line.code.replace('$buffer', this.getBuffer(this.blockLevel))));
|
941
|
+
this.blockLevel -= 1;
|
942
|
+
}
|
943
|
+
break;
|
944
|
+
case 'insert':
|
945
|
+
processors = '';
|
946
|
+
if (line.findAndPreserve) {
|
947
|
+
processors += '$fp ';
|
948
|
+
}
|
949
|
+
if (line.preserve) {
|
950
|
+
processors += '$p ';
|
951
|
+
}
|
952
|
+
if (line.escape) {
|
953
|
+
processors += '$e ';
|
954
|
+
}
|
955
|
+
if (this.options.cleanValue) {
|
956
|
+
processors += '$c ';
|
957
|
+
}
|
958
|
+
code.push("" + (whitespace(line.cw)) + (this.getBuffer(this.blockLevel)) + ".push \"" +
|
959
|
+
(whitespace(line.hw)) + "\" + " + processors + line.code);
|
960
|
+
if (line.block === 'start') {
|
961
|
+
this.blockLevel += 1;
|
962
|
+
code.push("" + (whitespace(line.cw + 1)) + (this.getBuffer(this.blockLevel)) +
|
963
|
+
" = []");
|
964
|
+
}
|
965
|
+
}
|
966
|
+
}
|
967
|
+
}
|
968
|
+
return code.join('\n');
|
969
|
+
};
|
970
|
+
|
971
|
+
HamlCoffee.prototype.getBuffer = function (level) {
|
972
|
+
if (level > 0) {
|
973
|
+
return "$o" + level;
|
974
|
+
} else {
|
975
|
+
return '$o';
|
976
|
+
}
|
977
|
+
};
|
978
|
+
|
979
|
+
HamlCoffee.prototype.combineText = function (lines) {
|
980
|
+
var combined, line, nextLine;
|
981
|
+
combined = [];
|
982
|
+
while ((line = lines.shift()) !== void 0) {
|
983
|
+
if (line.type === 'text') {
|
984
|
+
while (lines[0] && lines[0].type === 'text' && line.cw === lines[0].cw) {
|
985
|
+
nextLine = lines.shift();
|
986
|
+
line.text += "\\n" + (whitespace(nextLine.hw)) + nextLine.text;
|
987
|
+
}
|
988
|
+
}
|
989
|
+
combined.push(line);
|
990
|
+
}
|
991
|
+
return combined;
|
992
|
+
};
|
993
|
+
|
994
|
+
HamlCoffee.prototype.convertBooleans = function (code) {
|
995
|
+
if (code.indexOf('$c') !== -1 && !this.options.customCleanValue) {
|
996
|
+
if (this.options.format === 'xhtml') {
|
997
|
+
return '.replace(/\\s([\\w-]+)=\'\u0093true\'/mg, " $1=\'$1\'").replace(/\\s([\\w-]+)=\'\u0093false\'/mg, \'\')';
|
998
|
+
} else {
|
999
|
+
return '.replace(/\\s([\\w-]+)=\'\u0093true\'/mg, \' $1\').replace(/\\s([\\w-]+)=\'\u0093false\'/mg, \'\')';
|
1000
|
+
}
|
1001
|
+
} else {
|
1002
|
+
return '';
|
1003
|
+
}
|
1004
|
+
};
|
1005
|
+
|
1006
|
+
HamlCoffee.prototype.removeEmptyIDAndClass = function (code) {
|
1007
|
+
if (code.indexOf('id=') !== -1 || code.indexOf('class=') !== -1) {
|
1008
|
+
return '.replace(/\\s(?:id|class)=([\'"])(\\1)/mg, "")';
|
1009
|
+
} else {
|
1010
|
+
return '';
|
1011
|
+
}
|
1012
|
+
};
|
1013
|
+
|
1014
|
+
HamlCoffee.prototype.cleanupWhitespace = function (code) {
|
1015
|
+
if (/\u0091|\u0092/.test(code)) {
|
1016
|
+
return ".replace(/[\\s\\n]*\\u0091/mg, '').replace(/\\u0092[\\s\\n]*/mg, '')";
|
1017
|
+
} else {
|
1018
|
+
return '';
|
1019
|
+
}
|
1020
|
+
};
|
1021
|
+
|
1022
|
+
HamlCoffee.prototype.findDependencies = function (code) {
|
1023
|
+
var dependencies, match, module, name, requireRegexp;
|
1024
|
+
requireRegexp = /require(?:\s+|\()(['"])(.+?)(\1)\)?/gm;
|
1025
|
+
dependencies = {};
|
1026
|
+
while (match = requireRegexp.exec(code)) {
|
1027
|
+
module = match[2];
|
1028
|
+
name = module.split('/').pop();
|
1029
|
+
dependencies[name] = module;
|
1030
|
+
}
|
1031
|
+
return dependencies;
|
1032
|
+
};
|
1033
|
+
|
1034
|
+
return HamlCoffee;
|
1035
|
+
|
1036
|
+
})();
|
1037
|
+
|
1038
|
+
}).call(this);
|
1039
|
+
|
1040
|
+
});
|
1041
|
+
|
1042
|
+
require.define("/nodes/node.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
1043
|
+
(function () {
|
1044
|
+
var Node, escapeHTML;
|
1045
|
+
|
1046
|
+
escapeHTML = require('../util/text').escapeHTML;
|
1047
|
+
|
1048
|
+
module.exports = Node = (function () {
|
1049
|
+
Node.CLEAR_WHITESPACE_LEFT = '\u0091';
|
1050
|
+
|
1051
|
+
Node.CLEAR_WHITESPACE_RIGHT = '\u0092';
|
1052
|
+
|
1053
|
+
function Node(expression, options) {
|
1054
|
+
this.expression = expression != null ? expression : '';
|
1055
|
+
if (options == null) {
|
1056
|
+
options = {};
|
1057
|
+
}
|
1058
|
+
this.parentNode = options.parentNode;
|
1059
|
+
this.children = [];
|
1060
|
+
this.opener = this.closer = null;
|
1061
|
+
this.silent = false;
|
1062
|
+
this.preserveTags = options.preserveTags.split(',');
|
1063
|
+
this.preserve = false;
|
1064
|
+
this.wsRemoval = {
|
1065
|
+
around: false,
|
1066
|
+
inside: false
|
1067
|
+
};
|
1068
|
+
this.escapeHtml = options.escapeHtml;
|
1069
|
+
this.escapeAttributes = options.escapeAttributes;
|
1070
|
+
this.cleanValue = options.cleanValue;
|
1071
|
+
this.format = options.format;
|
1072
|
+
this.hyphenateDataAttrs = options.hyphenateDataAttrs;
|
1073
|
+
this.selfCloseTags = options.selfCloseTags.split(',');
|
1074
|
+
this.uglify = options.uglify;
|
1075
|
+
this.codeBlockLevel = options.codeBlockLevel;
|
1076
|
+
this.blockLevel = options.blockLevel;
|
1077
|
+
this.placement = options.placement;
|
1078
|
+
this.namespace = options.namespace;
|
1079
|
+
this.name = options.name;
|
1080
|
+
}
|
1081
|
+
|
1082
|
+
Node.prototype.addChild = function (child) {
|
1083
|
+
this.children.push(child);
|
1084
|
+
return this;
|
1085
|
+
};
|
1086
|
+
|
1087
|
+
Node.prototype.getOpener = function () {
|
1088
|
+
if (this.wsRemoval.around && this.opener.text) {
|
1089
|
+
this.opener.text = Node.CLEAR_WHITESPACE_LEFT + this.opener.text;
|
1090
|
+
}
|
1091
|
+
if (this.wsRemoval.inside && this.opener.text) {
|
1092
|
+
this.opener.text += Node.CLEAR_WHITESPACE_RIGHT;
|
1093
|
+
}
|
1094
|
+
return this.opener;
|
1095
|
+
};
|
1096
|
+
|
1097
|
+
Node.prototype.getCloser = function () {
|
1098
|
+
if (this.wsRemoval.inside && this.closer.text) {
|
1099
|
+
this.closer.text = Node.CLEAR_WHITESPACE_LEFT + this.closer.text;
|
1100
|
+
}
|
1101
|
+
if (this.wsRemoval.around && this.closer.text) {
|
1102
|
+
this.closer.text += Node.CLEAR_WHITESPACE_RIGHT;
|
1103
|
+
}
|
1104
|
+
return this.closer;
|
1105
|
+
};
|
1106
|
+
|
1107
|
+
Node.prototype.isPreserved = function () {
|
1108
|
+
if (this.preserve) {
|
1109
|
+
return true;
|
1110
|
+
}
|
1111
|
+
if (this.parentNode) {
|
1112
|
+
return this.parentNode.isPreserved();
|
1113
|
+
} else {
|
1114
|
+
return false;
|
1115
|
+
}
|
1116
|
+
};
|
1117
|
+
|
1118
|
+
Node.prototype.isCommented = function () {
|
1119
|
+
if (this.constructor.name === 'Comment') {
|
1120
|
+
return true;
|
1121
|
+
}
|
1122
|
+
if (this.parentNode) {
|
1123
|
+
return this.parentNode.isCommented();
|
1124
|
+
} else {
|
1125
|
+
return false;
|
1126
|
+
}
|
1127
|
+
};
|
1128
|
+
|
1129
|
+
Node.prototype.markText = function (text, escape) {
|
1130
|
+
if (escape == null) {
|
1131
|
+
escape = false;
|
1132
|
+
}
|
1133
|
+
return {
|
1134
|
+
type: 'text',
|
1135
|
+
cw: this.codeBlockLevel,
|
1136
|
+
hw: this.uglify ? 0 : this.blockLevel - this.codeBlockLevel,
|
1137
|
+
text: escape ? escapeHTML(text) : text
|
1138
|
+
};
|
1139
|
+
};
|
1140
|
+
|
1141
|
+
Node.prototype.markRunningCode = function (code) {
|
1142
|
+
return {
|
1143
|
+
type: 'run',
|
1144
|
+
cw: this.codeBlockLevel,
|
1145
|
+
code: code
|
1146
|
+
};
|
1147
|
+
};
|
1148
|
+
|
1149
|
+
Node.prototype.markInsertingCode = function (code, escape, preserve, findAndPreserve) {
|
1150
|
+
if (escape == null) {
|
1151
|
+
escape = false;
|
1152
|
+
}
|
1153
|
+
if (preserve == null) {
|
1154
|
+
preserve = false;
|
1155
|
+
}
|
1156
|
+
if (findAndPreserve == null) {
|
1157
|
+
findAndPreserve = false;
|
1158
|
+
}
|
1159
|
+
return {
|
1160
|
+
type: 'insert',
|
1161
|
+
cw: this.codeBlockLevel,
|
1162
|
+
hw: this.uglify ? 0 : this.blockLevel - this.codeBlockLevel,
|
1163
|
+
escape: escape,
|
1164
|
+
preserve: preserve,
|
1165
|
+
findAndPreserve: findAndPreserve,
|
1166
|
+
code: code
|
1167
|
+
};
|
1168
|
+
};
|
1169
|
+
|
1170
|
+
Node.prototype.evaluate = function () {
|
1171
|
+
};
|
1172
|
+
|
1173
|
+
Node.prototype.render = function () {
|
1174
|
+
var child, output, rendered, tag, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4;
|
1175
|
+
output = [];
|
1176
|
+
if (this.silent) {
|
1177
|
+
return output;
|
1178
|
+
}
|
1179
|
+
if (this.children.length === 0) {
|
1180
|
+
if (this.opener && this.closer) {
|
1181
|
+
tag = this.getOpener();
|
1182
|
+
tag.text += this.getCloser().text;
|
1183
|
+
output.push(tag);
|
1184
|
+
} else {
|
1185
|
+
if (!this.preserve && this.isPreserved()) {
|
1186
|
+
output.push(this.getOpener());
|
1187
|
+
} else {
|
1188
|
+
output.push(this.getOpener());
|
1189
|
+
}
|
1190
|
+
}
|
1191
|
+
} else {
|
1192
|
+
if (this.opener && this.closer) {
|
1193
|
+
if (this.preserve) {
|
1194
|
+
this.wsRemoval.inside = true;
|
1195
|
+
output.push(this.getOpener());
|
1196
|
+
_ref = this.children;
|
1197
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1198
|
+
child = _ref[_i];
|
1199
|
+
_ref1 = child.render();
|
1200
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
1201
|
+
rendered = _ref1[_j];
|
1202
|
+
rendered.hw = this.blockLevel;
|
1203
|
+
output.push(rendered);
|
1204
|
+
}
|
1205
|
+
}
|
1206
|
+
output.push(this.getCloser());
|
1207
|
+
} else {
|
1208
|
+
output.push(this.getOpener());
|
1209
|
+
_ref2 = this.children;
|
1210
|
+
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
1211
|
+
child = _ref2[_k];
|
1212
|
+
output = output.concat(child.render());
|
1213
|
+
}
|
1214
|
+
output.push(this.getCloser());
|
1215
|
+
}
|
1216
|
+
} else if (this.opener) {
|
1217
|
+
output.push(this.getOpener());
|
1218
|
+
_ref3 = this.children;
|
1219
|
+
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
1220
|
+
child = _ref3[_l];
|
1221
|
+
output = output.concat(child.render());
|
1222
|
+
}
|
1223
|
+
} else {
|
1224
|
+
_ref4 = this.children;
|
1225
|
+
for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
|
1226
|
+
child = _ref4[_m];
|
1227
|
+
output.push(this.markText(child.render().text));
|
1228
|
+
}
|
1229
|
+
}
|
1230
|
+
}
|
1231
|
+
return output;
|
1232
|
+
};
|
1233
|
+
|
1234
|
+
return Node;
|
1235
|
+
|
1236
|
+
})();
|
1237
|
+
|
1238
|
+
}).call(this);
|
1239
|
+
|
1240
|
+
});
|
1241
|
+
|
1242
|
+
require.define("/util/text.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
1243
|
+
(function () {
|
1244
|
+
module.exports = {
|
1245
|
+
whitespace: function (n) {
|
1246
|
+
var a;
|
1247
|
+
n = n * 2;
|
1248
|
+
a = [];
|
1249
|
+
while (a.length < n) {
|
1250
|
+
a.push(' ');
|
1251
|
+
}
|
1252
|
+
return a.join('');
|
1253
|
+
},
|
1254
|
+
escapeQuotes: function (text) {
|
1255
|
+
if (!text) {
|
1256
|
+
return '';
|
1257
|
+
}
|
1258
|
+
return text.replace(/"/g, '\\"').replace(/\\\\\"/g, '\\"');
|
1259
|
+
},
|
1260
|
+
unescapeQuotes: function (text) {
|
1261
|
+
if (!text) {
|
1262
|
+
return '';
|
1263
|
+
}
|
1264
|
+
return text.replace(/\\"/g, '"');
|
1265
|
+
},
|
1266
|
+
escapeHTML: function (text) {
|
1267
|
+
if (!text) {
|
1268
|
+
return '';
|
1269
|
+
}
|
1270
|
+
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"');
|
1271
|
+
},
|
1272
|
+
preserve: function (code) {
|
1273
|
+
if (code) {
|
1274
|
+
code.replace(/\r/g, '');
|
1275
|
+
return code.replace(/<(pre|textarea)>(.*?)<\/\1>/g, function (text) {
|
1276
|
+
return text.replace('\\n', '\&\#x000A;');
|
1277
|
+
});
|
1278
|
+
}
|
1279
|
+
},
|
1280
|
+
indent: function (text, spaces) {
|
1281
|
+
return text.replace(/^(.*)$/mg, module.exports.whitespace(spaces) + '$1');
|
1282
|
+
}
|
1283
|
+
};
|
1284
|
+
|
1285
|
+
}).call(this);
|
1286
|
+
|
1287
|
+
});
|
1288
|
+
|
1289
|
+
require.define("/nodes/text.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
1290
|
+
(function () {
|
1291
|
+
var Node, Text, escapeQuotes, _ref,
|
1292
|
+
__hasProp = {}.hasOwnProperty,
|
1293
|
+
__extends = function (child, parent) {
|
1294
|
+
for (var key in parent) {
|
1295
|
+
if (__hasProp.call(parent, key)) child[key] = parent[key];
|
1296
|
+
}
|
1297
|
+
function ctor() {
|
1298
|
+
this.constructor = child;
|
1299
|
+
}
|
1300
|
+
|
1301
|
+
ctor.prototype = parent.prototype;
|
1302
|
+
child.prototype = new ctor();
|
1303
|
+
child.__super__ = parent.prototype;
|
1304
|
+
return child;
|
1305
|
+
};
|
1306
|
+
|
1307
|
+
Node = require('./node');
|
1308
|
+
|
1309
|
+
escapeQuotes = require('../util/text').escapeQuotes;
|
1310
|
+
|
1311
|
+
module.exports = Text = (function (_super) {
|
1312
|
+
__extends(Text, _super);
|
1313
|
+
|
1314
|
+
function Text() {
|
1315
|
+
_ref = Text.__super__.constructor.apply(this, arguments);
|
1316
|
+
return _ref;
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
Text.prototype.evaluate = function () {
|
1320
|
+
return this.opener = this.markText(escapeQuotes(this.expression));
|
1321
|
+
};
|
1322
|
+
|
1323
|
+
return Text;
|
1324
|
+
|
1325
|
+
})(Node);
|
1326
|
+
|
1327
|
+
}).call(this);
|
1328
|
+
|
1329
|
+
});
|
1330
|
+
|
1331
|
+
require.define("/nodes/haml.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
1332
|
+
(function () {
|
1333
|
+
var Haml, Node, escapeQuotes, _ref,
|
1334
|
+
__hasProp = {}.hasOwnProperty,
|
1335
|
+
__extends = function (child, parent) {
|
1336
|
+
for (var key in parent) {
|
1337
|
+
if (__hasProp.call(parent, key)) child[key] = parent[key];
|
1338
|
+
}
|
1339
|
+
function ctor() {
|
1340
|
+
this.constructor = child;
|
1341
|
+
}
|
1342
|
+
|
1343
|
+
ctor.prototype = parent.prototype;
|
1344
|
+
child.prototype = new ctor();
|
1345
|
+
child.__super__ = parent.prototype;
|
1346
|
+
return child;
|
1347
|
+
};
|
1348
|
+
|
1349
|
+
Node = require('./node');
|
1350
|
+
|
1351
|
+
escapeQuotes = require('../util/text').escapeQuotes;
|
1352
|
+
|
1353
|
+
module.exports = Haml = (function (_super) {
|
1354
|
+
__extends(Haml, _super);
|
1355
|
+
|
1356
|
+
function Haml() {
|
1357
|
+
_ref = Haml.__super__.constructor.apply(this, arguments);
|
1358
|
+
return _ref;
|
1359
|
+
}
|
1360
|
+
|
1361
|
+
Haml.prototype.evaluate = function () {
|
1362
|
+
var assignment, code, identifier, match, prefix, tokens;
|
1363
|
+
tokens = this.parseExpression(this.expression);
|
1364
|
+
if (tokens.doctype) {
|
1365
|
+
return this.opener = this.markText("" + (escapeQuotes(this.buildDocType(tokens.doctype))));
|
1366
|
+
} else {
|
1367
|
+
if (this.isNotSelfClosing(tokens.tag)) {
|
1368
|
+
prefix = this.buildHtmlTagPrefix(tokens);
|
1369
|
+
if (tokens.assignment) {
|
1370
|
+
match = tokens.assignment.match(/^(=|!=|&=|~)\s*(.*)$/);
|
1371
|
+
identifier = match[1];
|
1372
|
+
assignment = match[2];
|
1373
|
+
if (identifier === '~') {
|
1374
|
+
code = "\#{$fp " + assignment + " }";
|
1375
|
+
} else if (identifier === '&=' || (identifier === '=' && this.escapeHtml)) {
|
1376
|
+
if (this.preserve) {
|
1377
|
+
if (this.cleanValue) {
|
1378
|
+
code = "\#{ $p($e($c(" + assignment + "))) }";
|
1379
|
+
} else {
|
1380
|
+
code = "\#{ $p($e(" + assignment + ")) }";
|
1381
|
+
}
|
1382
|
+
} else {
|
1383
|
+
if (this.cleanValue) {
|
1384
|
+
code = "\#{ $e($c(" + assignment + ")) }";
|
1385
|
+
} else {
|
1386
|
+
code = "\#{ $e(" + assignment + ") }";
|
1387
|
+
}
|
1388
|
+
}
|
1389
|
+
} else if (identifier === '!=' || (identifier === '=' && !this.escapeHtml)) {
|
1390
|
+
if (this.preserve) {
|
1391
|
+
if (this.cleanValue) {
|
1392
|
+
code = "\#{ $p($c(" + assignment + ")) }";
|
1393
|
+
} else {
|
1394
|
+
code = "\#{ $p(" + assignment + ") }";
|
1395
|
+
}
|
1396
|
+
} else {
|
1397
|
+
if (this.cleanValue) {
|
1398
|
+
code = "\#{ $c(" + assignment + ") }";
|
1399
|
+
} else {
|
1400
|
+
code = "\#{ " + assignment + " }";
|
1401
|
+
}
|
1402
|
+
}
|
1403
|
+
}
|
1404
|
+
this.opener = this.markText("" + prefix + ">" + code);
|
1405
|
+
return this.closer = this.markText("</" + tokens.tag + ">");
|
1406
|
+
} else if (tokens.text) {
|
1407
|
+
this.opener = this.markText("" + prefix + ">" + tokens.text);
|
1408
|
+
return this.closer = this.markText("</" + tokens.tag + ">");
|
1409
|
+
} else {
|
1410
|
+
this.opener = this.markText(prefix + '>');
|
1411
|
+
return this.closer = this.markText("</" + tokens.tag + ">");
|
1412
|
+
}
|
1413
|
+
} else {
|
1414
|
+
tokens.tag = tokens.tag.replace(/\/$/, '');
|
1415
|
+
prefix = this.buildHtmlTagPrefix(tokens);
|
1416
|
+
if (tokens.text) {
|
1417
|
+
this.opener = this.markText("" + prefix + ">" + tokens.text);
|
1418
|
+
return this.closer = this.markText("</" + tokens.tag + ">");
|
1419
|
+
} else {
|
1420
|
+
return this.opener =
|
1421
|
+
this.markText("" + prefix + (this.format === 'xhtml' ? ' /' : '') + ">" + tokens.text);
|
1422
|
+
}
|
1423
|
+
}
|
1424
|
+
}
|
1425
|
+
};
|
1426
|
+
|
1427
|
+
Haml.prototype.parseExpression = function (exp) {
|
1428
|
+
var attributes, classes, id, key, tag, value, _ref1, _ref2;
|
1429
|
+
tag = this.parseTag(exp);
|
1430
|
+
if (this.preserveTags.indexOf(tag.tag) !== -1) {
|
1431
|
+
this.preserve = true;
|
1432
|
+
}
|
1433
|
+
id = this.interpolateCodeAttribute((_ref1 = tag.ids) != null ? _ref1.pop() : void 0, true);
|
1434
|
+
classes = tag.classes;
|
1435
|
+
attributes = {};
|
1436
|
+
if (tag.attributes) {
|
1437
|
+
_ref2 = tag.attributes;
|
1438
|
+
for (key in _ref2) {
|
1439
|
+
value = _ref2[key];
|
1440
|
+
if (key === 'id') {
|
1441
|
+
if (id) {
|
1442
|
+
id += '_' + this.interpolateCodeAttribute(value, true);
|
1443
|
+
} else {
|
1444
|
+
id = this.interpolateCodeAttribute(value, true);
|
1445
|
+
}
|
1446
|
+
} else if (key === 'class') {
|
1447
|
+
classes || (classes = []);
|
1448
|
+
classes.push(value);
|
1449
|
+
} else {
|
1450
|
+
attributes[key] = value;
|
1451
|
+
}
|
1452
|
+
}
|
1453
|
+
}
|
1454
|
+
return {
|
1455
|
+
doctype: tag.doctype,
|
1456
|
+
tag: tag.tag,
|
1457
|
+
id: id,
|
1458
|
+
classes: classes,
|
1459
|
+
text: escapeQuotes(tag.text),
|
1460
|
+
attributes: attributes,
|
1461
|
+
assignment: tag.assignment,
|
1462
|
+
reference: tag.reference
|
1463
|
+
};
|
1464
|
+
};
|
1465
|
+
|
1466
|
+
Haml.prototype.parseTag = function (exp) {
|
1467
|
+
var assignment, attr, attributes, ch, classes, doctype, end, error, haml, htmlAttributes, id, ids, key, klass, level, pos, reference, rest, rubyAttributes, start, tag, text, val, whitespace, _i, _j, _k, _len, _len1, _ref1, _ref2, _ref3, _ref4, _ref5;
|
1468
|
+
try {
|
1469
|
+
doctype = (_ref1 = exp.match(/^(\!{3}.*)/)) != null ? _ref1[1] : void 0;
|
1470
|
+
if (doctype) {
|
1471
|
+
return {
|
1472
|
+
doctype: doctype
|
1473
|
+
};
|
1474
|
+
}
|
1475
|
+
haml = exp.match(/^((?:[#%\.][a-z0-9_:\-]*[\/]?)+)/i)[0];
|
1476
|
+
rest = exp.substring(haml.length);
|
1477
|
+
if (rest.match(/^[{([]/)) {
|
1478
|
+
reference = '';
|
1479
|
+
htmlAttributes = '';
|
1480
|
+
rubyAttributes = '';
|
1481
|
+
_ref2 = ['[', '{', '(', '[', '{', '('];
|
1482
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
1483
|
+
start = _ref2[_i];
|
1484
|
+
if (start === rest[0]) {
|
1485
|
+
end = (function () {
|
1486
|
+
switch (start) {
|
1487
|
+
case '{':
|
1488
|
+
return '}';
|
1489
|
+
case '(':
|
1490
|
+
return ')';
|
1491
|
+
case '[':
|
1492
|
+
return ']';
|
1493
|
+
}
|
1494
|
+
})();
|
1495
|
+
level = 0;
|
1496
|
+
for (pos = _j = 0, _ref3 = rest.length; 0 <= _ref3 ? _j <= _ref3 : _j >= _ref3; pos =
|
1497
|
+
0 <= _ref3 ? ++_j : --_j) {
|
1498
|
+
ch = rest[pos];
|
1499
|
+
if (ch === start) {
|
1500
|
+
level += 1;
|
1501
|
+
}
|
1502
|
+
if (ch === end) {
|
1503
|
+
if (level === 1) {
|
1504
|
+
break;
|
1505
|
+
} else {
|
1506
|
+
level -= 1;
|
1507
|
+
}
|
1508
|
+
}
|
1509
|
+
}
|
1510
|
+
switch (start) {
|
1511
|
+
case '{':
|
1512
|
+
rubyAttributes += rest.substring(0, pos + 1);
|
1513
|
+
rest = rest.substring(pos + 1);
|
1514
|
+
break;
|
1515
|
+
case '(':
|
1516
|
+
htmlAttributes += rest.substring(0, pos + 1);
|
1517
|
+
rest = rest.substring(pos + 1);
|
1518
|
+
break;
|
1519
|
+
case '[':
|
1520
|
+
reference = rest.substring(1, pos);
|
1521
|
+
rest = rest.substring(pos + 1);
|
1522
|
+
}
|
1523
|
+
}
|
1524
|
+
}
|
1525
|
+
assignment = rest || '';
|
1526
|
+
} else {
|
1527
|
+
reference = '';
|
1528
|
+
htmlAttributes = '';
|
1529
|
+
rubyAttributes = '';
|
1530
|
+
assignment = rest;
|
1531
|
+
}
|
1532
|
+
attributes = {};
|
1533
|
+
_ref4 = [this.parseAttributes(htmlAttributes), this.parseAttributes(rubyAttributes)];
|
1534
|
+
for (_k = 0, _len1 = _ref4.length; _k < _len1; _k++) {
|
1535
|
+
attr = _ref4[_k];
|
1536
|
+
for (key in attr) {
|
1537
|
+
val = attr[key];
|
1538
|
+
attributes[key] = val;
|
1539
|
+
}
|
1540
|
+
}
|
1541
|
+
if (whitespace = (_ref5 = assignment.match(/^[<>]{0,2}/)) != null ? _ref5[0] : void 0) {
|
1542
|
+
assignment = assignment.substring(whitespace.length);
|
1543
|
+
}
|
1544
|
+
if (assignment[0] === ' ') {
|
1545
|
+
assignment = assignment.substring(1);
|
1546
|
+
}
|
1547
|
+
if (assignment && !assignment.match(/^(=|!=|&=|~)/)) {
|
1548
|
+
text = assignment.replace(/^ /, '');
|
1549
|
+
assignment = void 0;
|
1550
|
+
}
|
1551
|
+
if (whitespace) {
|
1552
|
+
if (whitespace.indexOf('>') !== -1) {
|
1553
|
+
this.wsRemoval.around = true;
|
1554
|
+
}
|
1555
|
+
if (whitespace.indexOf('<') !== -1) {
|
1556
|
+
this.wsRemoval.inside = true;
|
1557
|
+
this.preserve = true;
|
1558
|
+
}
|
1559
|
+
}
|
1560
|
+
tag = haml.match(/\%([a-z_\-][a-z0-9_:\-]*[\/]?)/i);
|
1561
|
+
ids = haml.match(/\#([a-z_\-][a-z0-9_\-]*)/gi);
|
1562
|
+
classes = haml.match(/\.([a-z0-9_\-]*)/gi);
|
1563
|
+
return {
|
1564
|
+
tag: tag ? tag[1] : 'div',
|
1565
|
+
ids: ids ? (function () {
|
1566
|
+
var _l, _len2, _results;
|
1567
|
+
_results = [];
|
1568
|
+
for (_l = 0, _len2 = ids.length; _l < _len2; _l++) {
|
1569
|
+
id = ids[_l];
|
1570
|
+
_results.push("'" + (id.substr(1)) + "'");
|
1571
|
+
}
|
1572
|
+
return _results;
|
1573
|
+
})() : void 0,
|
1574
|
+
classes: classes ? (function () {
|
1575
|
+
var _l, _len2, _results;
|
1576
|
+
_results = [];
|
1577
|
+
for (_l = 0, _len2 = classes.length; _l < _len2; _l++) {
|
1578
|
+
klass = classes[_l];
|
1579
|
+
_results.push("'" + (klass.substr(1)) + "'");
|
1580
|
+
}
|
1581
|
+
return _results;
|
1582
|
+
})() : void 0,
|
1583
|
+
attributes: attributes,
|
1584
|
+
assignment: assignment,
|
1585
|
+
reference: reference,
|
1586
|
+
text: text
|
1587
|
+
};
|
1588
|
+
} catch (_error) {
|
1589
|
+
error = _error;
|
1590
|
+
throw new Error("Unable to parse tag from " + exp + ": " + error);
|
1591
|
+
}
|
1592
|
+
};
|
1593
|
+
|
1594
|
+
Haml.prototype.parseAttributes = function (exp) {
|
1595
|
+
var attr, attributes, ch, endPos, hasDataAttribute, inDataAttribute, key, keyValue, keys, level, marker, markers, pairs, pos, quote, quoted, start, startPos, type, value, _i, _j, _k, _len, _len1, _ref1, _ref2, _ref3, _ref4, _ref5;
|
1596
|
+
attributes = {};
|
1597
|
+
if (exp === void 0) {
|
1598
|
+
return attributes;
|
1599
|
+
}
|
1600
|
+
type = exp.substring(0, 1);
|
1601
|
+
exp =
|
1602
|
+
exp.replace(/(=|:|=>)\s*('([^\\']|\\\\|\\')*'|"([^\\"]|\\\\|\\")*")/g, function (match, type, value) {
|
1603
|
+
return type + (value != null ? value.replace(/(:|=|=>)/g, '\u0090$1') : void 0);
|
1604
|
+
});
|
1605
|
+
level = 0;
|
1606
|
+
start = 0;
|
1607
|
+
markers = [];
|
1608
|
+
if (type === '(') {
|
1609
|
+
startPos = 1;
|
1610
|
+
endPos = exp.length - 1;
|
1611
|
+
} else {
|
1612
|
+
startPos = 0;
|
1613
|
+
endPos = exp.length;
|
1614
|
+
}
|
1615
|
+
for (pos = _i = startPos; startPos <= endPos ? _i < endPos : _i > endPos; pos =
|
1616
|
+
startPos <= endPos ? ++_i : --_i) {
|
1617
|
+
ch = exp[pos];
|
1618
|
+
if (ch === '(') {
|
1619
|
+
level += 1;
|
1620
|
+
if (level === 1) {
|
1621
|
+
start = pos;
|
1622
|
+
}
|
1623
|
+
}
|
1624
|
+
if (ch === ')') {
|
1625
|
+
if (level === 1) {
|
1626
|
+
if (start !== 0 && pos - start !== 1) {
|
1627
|
+
markers.push({
|
1628
|
+
start: start,
|
1629
|
+
end: pos
|
1630
|
+
});
|
1631
|
+
}
|
1632
|
+
} else {
|
1633
|
+
level -= 1;
|
1634
|
+
}
|
1635
|
+
}
|
1636
|
+
}
|
1637
|
+
_ref1 = markers.reverse();
|
1638
|
+
for (_j = 0, _len = _ref1.length; _j < _len; _j++) {
|
1639
|
+
marker = _ref1[_j];
|
1640
|
+
exp = exp.substring(0, marker.start) +
|
1641
|
+
exp.substring(marker.start, marker.end).replace(/(:|=|=>)/g, '\u0090$1') +
|
1642
|
+
exp.substring(marker.end);
|
1643
|
+
}
|
1644
|
+
switch (type) {
|
1645
|
+
case '(':
|
1646
|
+
keys =
|
1647
|
+
/\(\s*([-\w]+[\w:-]*\w?)\s*=|\s+([-\w]+[\w:-]*\w?)\s*=|\(\s*('\w+[\w:-]*\w?')\s*=|\s+('\w+[\w:-]*\w?')\s*=|\(\s*("\w+[\w:-]*\w?")\s*=|\s+("\w+[\w:-]*\w?")\s*=/g;
|
1648
|
+
break;
|
1649
|
+
case '{':
|
1650
|
+
keys =
|
1651
|
+
/[{,]\s*(\w+[\w:-]*\w?)\s*:|[{,]\s*('[-\w]+[\w:-]*\w?')\s*:|[{,]\s*("[-\w]+[\w:-]*\w?")\s*:|[{,]\s*:(\w+[\w:-]*\w?)\s*=>|[{,]\s*:?'([-\w]+[\w:-]*\w?)'\s*=>|[{,]\s*:?"([-\w]+[\w:-]*\w?)"\s*=>/g;
|
1652
|
+
}
|
1653
|
+
pairs = exp.split(keys).filter(Boolean);
|
1654
|
+
inDataAttribute = false;
|
1655
|
+
hasDataAttribute = false;
|
1656
|
+
while (pairs.length) {
|
1657
|
+
keyValue = pairs.splice(0, 2);
|
1658
|
+
if (keyValue.length === 1) {
|
1659
|
+
attr = keyValue[0].replace(/^[\s({]+|[\s)}]+$/g, '');
|
1660
|
+
attributes[attr] = 'true';
|
1661
|
+
} else {
|
1662
|
+
key = (_ref2 = keyValue[0]) != null ? _ref2.replace(/^\s+|\s+$/g, '').replace(/^:/, '') :
|
1663
|
+
void 0;
|
1664
|
+
if (quoted = key.match(/^("|')(.*)\1$/)) {
|
1665
|
+
key = quoted[2];
|
1666
|
+
}
|
1667
|
+
value = (_ref3 = keyValue[1]) != null ?
|
1668
|
+
_ref3.replace(/^\s+|[\s,]+$/g, '').replace(/\u0090/g, '') : void 0;
|
1669
|
+
if (key === 'data' && !value) {
|
1670
|
+
inDataAttribute = true;
|
1671
|
+
hasDataAttribute = true;
|
1672
|
+
} else if (key && value) {
|
1673
|
+
if (inDataAttribute) {
|
1674
|
+
key = this.hyphenateDataAttrs ? "data-" + (key.replace('_', '-')) : "data-" + key;
|
1675
|
+
if (/}\s*$/.test(value)) {
|
1676
|
+
inDataAttribute = false;
|
1677
|
+
}
|
1678
|
+
}
|
1679
|
+
}
|
1680
|
+
switch (type) {
|
1681
|
+
case '(':
|
1682
|
+
value = value.replace(/^\s+|[\s)]+$/g, '');
|
1683
|
+
quote = (_ref4 = /^(['"])/.exec(value)) != null ? _ref4[1] : void 0;
|
1684
|
+
pos = value.lastIndexOf(quote);
|
1685
|
+
if (pos > 1) {
|
1686
|
+
_ref5 = value.substring(pos + 1).split(' ');
|
1687
|
+
for (_k = 0, _len1 = _ref5.length; _k < _len1; _k++) {
|
1688
|
+
attr = _ref5[_k];
|
1689
|
+
if (attr) {
|
1690
|
+
attributes[attr] = 'true';
|
1691
|
+
}
|
1692
|
+
}
|
1693
|
+
value = value.substring(0, pos + 1);
|
1694
|
+
}
|
1695
|
+
attributes[key] = value;
|
1696
|
+
break;
|
1697
|
+
case '{':
|
1698
|
+
attributes[key] = value.replace(/^\s+|[\s}]+$/g, '');
|
1699
|
+
}
|
1700
|
+
}
|
1701
|
+
}
|
1702
|
+
if (hasDataAttribute) {
|
1703
|
+
delete attributes['data'];
|
1704
|
+
}
|
1705
|
+
return attributes;
|
1706
|
+
};
|
1707
|
+
|
1708
|
+
Haml.prototype.buildHtmlTagPrefix = function (tokens) {
|
1709
|
+
var classList, classes, hasDynamicClass, key, klass, name, tagParts, value, _i, _len, _ref1;
|
1710
|
+
tagParts = ["<" + tokens.tag];
|
1711
|
+
if (tokens.classes) {
|
1712
|
+
hasDynamicClass = false;
|
1713
|
+
classList = (function () {
|
1714
|
+
var _i, _len, _ref1, _results;
|
1715
|
+
_ref1 = tokens.classes;
|
1716
|
+
_results = [];
|
1717
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
1718
|
+
name = _ref1[_i];
|
1719
|
+
name = this.interpolateCodeAttribute(name, true);
|
1720
|
+
if (name.indexOf('#{') !== -1) {
|
1721
|
+
hasDynamicClass = true;
|
1722
|
+
}
|
1723
|
+
_results.push(name);
|
1724
|
+
}
|
1725
|
+
return _results;
|
1726
|
+
}).call(this);
|
1727
|
+
if (hasDynamicClass && classList.length > 1) {
|
1728
|
+
classes = '#{ [';
|
1729
|
+
for (_i = 0, _len = classList.length; _i < _len; _i++) {
|
1730
|
+
klass = classList[_i];
|
1731
|
+
classes += "" + (this.quoteAndEscapeAttributeValue(klass, true)) + ",";
|
1732
|
+
}
|
1733
|
+
classes = classes.substring(0, classes.length - 1) +
|
1734
|
+
'].sort().join(\' \').replace(/^\\s+|\\s+$/g, \'\') }';
|
1735
|
+
} else {
|
1736
|
+
classes = classList.sort().join(' ');
|
1737
|
+
}
|
1738
|
+
tagParts.push("class='" + classes + "'");
|
1739
|
+
}
|
1740
|
+
if (tokens.id) {
|
1741
|
+
tagParts.push("id='" + tokens.id + "'");
|
1742
|
+
}
|
1743
|
+
if (tokens.reference) {
|
1744
|
+
if (tokens.attributes) {
|
1745
|
+
delete tokens.attributes['class'];
|
1746
|
+
delete tokens.attributes['id'];
|
1747
|
+
}
|
1748
|
+
tagParts.push("\#{$r(" + tokens.reference + ")}");
|
1749
|
+
}
|
1750
|
+
if (tokens.attributes) {
|
1751
|
+
_ref1 = tokens.attributes;
|
1752
|
+
for (key in _ref1) {
|
1753
|
+
value = _ref1[key];
|
1754
|
+
if (value === 'true' || value === 'false') {
|
1755
|
+
if (value === 'true') {
|
1756
|
+
if (this.format === 'html5') {
|
1757
|
+
tagParts.push("" + key);
|
1758
|
+
} else {
|
1759
|
+
tagParts.push("" + key + "=" + (this.quoteAndEscapeAttributeValue(key)));
|
1760
|
+
}
|
1761
|
+
}
|
1762
|
+
} else {
|
1763
|
+
tagParts.push("" + key + "=" +
|
1764
|
+
(this.quoteAndEscapeAttributeValue(this.interpolateCodeAttribute(value))));
|
1765
|
+
}
|
1766
|
+
}
|
1767
|
+
}
|
1768
|
+
return tagParts.join(' ');
|
1769
|
+
};
|
1770
|
+
|
1771
|
+
Haml.prototype.interpolateCodeAttribute = function (text, unwrap) {
|
1772
|
+
var quoted;
|
1773
|
+
if (unwrap == null) {
|
1774
|
+
unwrap = false;
|
1775
|
+
}
|
1776
|
+
if (!text) {
|
1777
|
+
return;
|
1778
|
+
}
|
1779
|
+
if (!text.match(/^("|').*\1$/)) {
|
1780
|
+
if (this.escapeAttributes) {
|
1781
|
+
if (this.cleanValue) {
|
1782
|
+
text = '#{ $e($c(' + text + ')) }';
|
1783
|
+
} else {
|
1784
|
+
text = '#{ $e(' + text + ') }';
|
1785
|
+
}
|
1786
|
+
} else {
|
1787
|
+
if (this.cleanValue) {
|
1788
|
+
text = '#{ $c(' + text + ') }';
|
1789
|
+
} else {
|
1790
|
+
text = '#{ (' + text + ') }';
|
1791
|
+
}
|
1792
|
+
}
|
1793
|
+
}
|
1794
|
+
if (unwrap) {
|
1795
|
+
if (quoted = text.match(/^("|')(.*)\1$/)) {
|
1796
|
+
text = quoted[2];
|
1797
|
+
}
|
1798
|
+
}
|
1799
|
+
return text;
|
1800
|
+
};
|
1801
|
+
|
1802
|
+
Haml.prototype.quoteAndEscapeAttributeValue = function (value, code) {
|
1803
|
+
var escaped, hasDoubleQuotes, hasInterpolation, hasSingleQuotes, quoted, result, token, tokens;
|
1804
|
+
if (code == null) {
|
1805
|
+
code = false;
|
1806
|
+
}
|
1807
|
+
if (!value) {
|
1808
|
+
return;
|
1809
|
+
}
|
1810
|
+
if (quoted = value.match(/^("|')(.*)\1$/)) {
|
1811
|
+
value = quoted[2];
|
1812
|
+
}
|
1813
|
+
tokens = this.splitInterpolations(value);
|
1814
|
+
hasSingleQuotes = false;
|
1815
|
+
hasDoubleQuotes = false;
|
1816
|
+
hasInterpolation = false;
|
1817
|
+
tokens = (function () {
|
1818
|
+
var _i, _len, _results;
|
1819
|
+
_results = [];
|
1820
|
+
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
|
1821
|
+
token = tokens[_i];
|
1822
|
+
if (token.slice(0, 2) === '#{') {
|
1823
|
+
if (token.indexOf('$e') === -1 && token.indexOf('$c') === -1) {
|
1824
|
+
if (this.escapeAttributes) {
|
1825
|
+
if (this.cleanValue) {
|
1826
|
+
token = '#{ $e($c(' + token.slice(2, -1) + ')) }';
|
1827
|
+
} else {
|
1828
|
+
token = '#{ $e(' + token.slice(2, -1) + ') }';
|
1829
|
+
}
|
1830
|
+
} else {
|
1831
|
+
if (this.cleanValue) {
|
1832
|
+
token = '#{ $c(' + token.slice(2, -1) + ') }';
|
1833
|
+
}
|
1834
|
+
}
|
1835
|
+
}
|
1836
|
+
hasInterpolation = true;
|
1837
|
+
} else {
|
1838
|
+
if (!hasSingleQuotes) {
|
1839
|
+
hasSingleQuotes = token.indexOf("'") !== -1;
|
1840
|
+
}
|
1841
|
+
if (!hasDoubleQuotes) {
|
1842
|
+
hasDoubleQuotes = token.indexOf('"') !== -1;
|
1843
|
+
}
|
1844
|
+
}
|
1845
|
+
_results.push(token);
|
1846
|
+
}
|
1847
|
+
return _results;
|
1848
|
+
}).call(this);
|
1849
|
+
if (code) {
|
1850
|
+
if (hasInterpolation) {
|
1851
|
+
result = "\"" + (tokens.join('')) + "\"";
|
1852
|
+
} else {
|
1853
|
+
result = "'" + (tokens.join('')) + "'";
|
1854
|
+
}
|
1855
|
+
} else {
|
1856
|
+
if (!hasDoubleQuotes && !hasSingleQuotes) {
|
1857
|
+
result = "'" + (tokens.join('')) + "'";
|
1858
|
+
}
|
1859
|
+
if (hasSingleQuotes && !hasDoubleQuotes) {
|
1860
|
+
result = "\\\"" + (tokens.join('')) + "\\\"";
|
1861
|
+
}
|
1862
|
+
if (hasDoubleQuotes && !hasSingleQuotes) {
|
1863
|
+
escaped = (function () {
|
1864
|
+
var _i, _len, _results;
|
1865
|
+
_results = [];
|
1866
|
+
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
|
1867
|
+
token = tokens[_i];
|
1868
|
+
_results.push(escapeQuotes(token));
|
1869
|
+
}
|
1870
|
+
return _results;
|
1871
|
+
})();
|
1872
|
+
result = "'" + (escaped.join('')) + "'";
|
1873
|
+
}
|
1874
|
+
if (hasSingleQuotes && hasDoubleQuotes) {
|
1875
|
+
escaped = (function () {
|
1876
|
+
var _i, _len, _results;
|
1877
|
+
_results = [];
|
1878
|
+
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
|
1879
|
+
token = tokens[_i];
|
1880
|
+
_results.push(escapeQuotes(token).replace(/'/g, '''));
|
1881
|
+
}
|
1882
|
+
return _results;
|
1883
|
+
})();
|
1884
|
+
result = "'" + (escaped.join('')) + "'";
|
1885
|
+
}
|
1886
|
+
}
|
1887
|
+
return result;
|
1888
|
+
};
|
1889
|
+
|
1890
|
+
Haml.prototype.splitInterpolations = function (value) {
|
1891
|
+
var ch, ch2, level, pos, start, tokens, _i, _ref1;
|
1892
|
+
level = 0;
|
1893
|
+
start = 0;
|
1894
|
+
tokens = [];
|
1895
|
+
for (pos = _i = 0, _ref1 = value.length; 0 <= _ref1 ? _i < _ref1 : _i > _ref1; pos =
|
1896
|
+
0 <= _ref1 ? ++_i : --_i) {
|
1897
|
+
ch = value[pos];
|
1898
|
+
ch2 = value.slice(pos, +(pos + 1) + 1 || 9e9);
|
1899
|
+
if (ch === '{') {
|
1900
|
+
level += 1;
|
1901
|
+
}
|
1902
|
+
if (ch2 === '#{' && level === 0) {
|
1903
|
+
tokens.push(value.slice(start, pos));
|
1904
|
+
start = pos;
|
1905
|
+
}
|
1906
|
+
if (ch === '}') {
|
1907
|
+
level -= 1;
|
1908
|
+
if (level === 0) {
|
1909
|
+
tokens.push(value.slice(start, +pos + 1 || 9e9));
|
1910
|
+
start = pos + 1;
|
1911
|
+
}
|
1912
|
+
}
|
1913
|
+
}
|
1914
|
+
tokens.push(value.slice(start, value.length));
|
1915
|
+
return tokens.filter(Boolean);
|
1916
|
+
};
|
1917
|
+
|
1918
|
+
Haml.prototype.buildDocType = function (doctype) {
|
1919
|
+
switch ("" + this.format + " " + doctype) {
|
1920
|
+
case 'xhtml !!! XML':
|
1921
|
+
return '<?xml version=\'1.0\' encoding=\'utf-8\' ?>';
|
1922
|
+
case 'xhtml !!!':
|
1923
|
+
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
1924
|
+
case 'xhtml !!! 1.1':
|
1925
|
+
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
|
1926
|
+
case 'xhtml !!! mobile':
|
1927
|
+
return '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">';
|
1928
|
+
case 'xhtml !!! basic':
|
1929
|
+
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">';
|
1930
|
+
case 'xhtml !!! frameset':
|
1931
|
+
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
|
1932
|
+
case 'xhtml !!! 5':
|
1933
|
+
case 'html5 !!!':
|
1934
|
+
return '<!DOCTYPE html>';
|
1935
|
+
case 'html5 !!! XML':
|
1936
|
+
case 'html4 !!! XML':
|
1937
|
+
return '';
|
1938
|
+
case 'html4 !!!':
|
1939
|
+
return '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
|
1940
|
+
case 'html4 !!! frameset':
|
1941
|
+
return '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
|
1942
|
+
case 'html4 !!! strict':
|
1943
|
+
return '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
|
1944
|
+
}
|
1945
|
+
};
|
1946
|
+
|
1947
|
+
Haml.prototype.isNotSelfClosing = function (tag) {
|
1948
|
+
return this.selfCloseTags.indexOf(tag) === -1 && !tag.match(/\/$/);
|
1949
|
+
};
|
1950
|
+
|
1951
|
+
return Haml;
|
1952
|
+
|
1953
|
+
})(Node);
|
1954
|
+
|
1955
|
+
}).call(this);
|
1956
|
+
|
1957
|
+
});
|
1958
|
+
|
1959
|
+
require.define("/nodes/code.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
1960
|
+
(function () {
|
1961
|
+
var Code, Node, _ref,
|
1962
|
+
__hasProp = {}.hasOwnProperty,
|
1963
|
+
__extends = function (child, parent) {
|
1964
|
+
for (var key in parent) {
|
1965
|
+
if (__hasProp.call(parent, key)) child[key] = parent[key];
|
1966
|
+
}
|
1967
|
+
function ctor() {
|
1968
|
+
this.constructor = child;
|
1969
|
+
}
|
1970
|
+
|
1971
|
+
ctor.prototype = parent.prototype;
|
1972
|
+
child.prototype = new ctor();
|
1973
|
+
child.__super__ = parent.prototype;
|
1974
|
+
return child;
|
1975
|
+
};
|
1976
|
+
|
1977
|
+
Node = require('./node');
|
1978
|
+
|
1979
|
+
module.exports = Code = (function (_super) {
|
1980
|
+
__extends(Code, _super);
|
1981
|
+
|
1982
|
+
function Code() {
|
1983
|
+
_ref = Code.__super__.constructor.apply(this, arguments);
|
1984
|
+
return _ref;
|
1985
|
+
}
|
1986
|
+
|
1987
|
+
Code.prototype.evaluate = function () {
|
1988
|
+
var code, codeBlock, escape, identifier;
|
1989
|
+
codeBlock = this.expression.match(/(-|!=|\&=|=|~)\s?(.*)?/);
|
1990
|
+
identifier = codeBlock[1];
|
1991
|
+
code = codeBlock[2];
|
1992
|
+
if (identifier === '-') {
|
1993
|
+
this.opener = this.markRunningCode(code);
|
1994
|
+
if (this.children.length !== 0 && this.opener.code.match(/(->|=>)/)) {
|
1995
|
+
return this.closer = this.markRunningCode(" ''");
|
1996
|
+
}
|
1997
|
+
} else if (identifier === '~') {
|
1998
|
+
if (this.escapeHtml) {
|
1999
|
+
return this.opener = this.markInsertingCode(code, true, false, true);
|
2000
|
+
} else {
|
2001
|
+
return this.opener = this.markInsertingCode(code, false, false, true);
|
2002
|
+
}
|
2003
|
+
} else {
|
2004
|
+
escape = identifier === '&=' || (identifier === '=' && this.escapeHtml);
|
2005
|
+
if (this.children.length !== 0 && code.match(/(->|=>)$/)) {
|
2006
|
+
this.opener = this.markInsertingCode(code, escape, false, false);
|
2007
|
+
this.opener.block = 'start';
|
2008
|
+
this.closer = this.markRunningCode(" $buffer.join \"\\n\"");
|
2009
|
+
return this.closer.block = 'end';
|
2010
|
+
} else {
|
2011
|
+
return this.opener = this.markInsertingCode(code, escape);
|
2012
|
+
}
|
2013
|
+
}
|
2014
|
+
};
|
2015
|
+
|
2016
|
+
return Code;
|
2017
|
+
|
2018
|
+
})(Node);
|
2019
|
+
|
2020
|
+
}).call(this);
|
2021
|
+
|
2022
|
+
});
|
2023
|
+
|
2024
|
+
require.define("/nodes/comment.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
2025
|
+
(function () {
|
2026
|
+
var Comment, Node, escapeQuotes, _ref,
|
2027
|
+
__hasProp = {}.hasOwnProperty,
|
2028
|
+
__extends = function (child, parent) {
|
2029
|
+
for (var key in parent) {
|
2030
|
+
if (__hasProp.call(parent, key)) child[key] = parent[key];
|
2031
|
+
}
|
2032
|
+
function ctor() {
|
2033
|
+
this.constructor = child;
|
2034
|
+
}
|
2035
|
+
|
2036
|
+
ctor.prototype = parent.prototype;
|
2037
|
+
child.prototype = new ctor();
|
2038
|
+
child.__super__ = parent.prototype;
|
2039
|
+
return child;
|
2040
|
+
};
|
2041
|
+
|
2042
|
+
Node = require('./node');
|
2043
|
+
|
2044
|
+
escapeQuotes = require('../util/text').escapeQuotes;
|
2045
|
+
|
2046
|
+
module.exports = Comment = (function (_super) {
|
2047
|
+
__extends(Comment, _super);
|
2048
|
+
|
2049
|
+
function Comment() {
|
2050
|
+
_ref = Comment.__super__.constructor.apply(this, arguments);
|
2051
|
+
return _ref;
|
2052
|
+
}
|
2053
|
+
|
2054
|
+
Comment.prototype.evaluate = function () {
|
2055
|
+
var comment, expression, identifier, _ref1;
|
2056
|
+
_ref1 = this.expression.match(/(-#|\/\[|\/)\s?(.*)?/), expression = _ref1[0], identifier =
|
2057
|
+
_ref1[1], comment = _ref1[2];
|
2058
|
+
switch (identifier) {
|
2059
|
+
case '-#':
|
2060
|
+
this.silent = true;
|
2061
|
+
return this.opener = this.markText('');
|
2062
|
+
case '\/[':
|
2063
|
+
this.opener = this.markText("<!--[" + comment + ">");
|
2064
|
+
return this.closer = this.markText('<![endif]-->');
|
2065
|
+
case '\/':
|
2066
|
+
if (comment) {
|
2067
|
+
this.opener = this.markText("<!-- " + (escapeQuotes(comment)));
|
2068
|
+
return this.closer = this.markText(' -->');
|
2069
|
+
} else {
|
2070
|
+
this.opener = this.markText("<!--");
|
2071
|
+
return this.closer = this.markText('-->');
|
2072
|
+
}
|
2073
|
+
}
|
2074
|
+
};
|
2075
|
+
|
2076
|
+
return Comment;
|
2077
|
+
|
2078
|
+
})(Node);
|
2079
|
+
|
2080
|
+
}).call(this);
|
2081
|
+
|
2082
|
+
});
|
2083
|
+
|
2084
|
+
require.define("/nodes/filter.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
2085
|
+
(function () {
|
2086
|
+
var Filter, Node, unescapeQuotes, whitespace, _ref,
|
2087
|
+
__hasProp = {}.hasOwnProperty,
|
2088
|
+
__extends = function (child, parent) {
|
2089
|
+
for (var key in parent) {
|
2090
|
+
if (__hasProp.call(parent, key)) child[key] = parent[key];
|
2091
|
+
}
|
2092
|
+
function ctor() {
|
2093
|
+
this.constructor = child;
|
2094
|
+
}
|
2095
|
+
|
2096
|
+
ctor.prototype = parent.prototype;
|
2097
|
+
child.prototype = new ctor();
|
2098
|
+
child.__super__ = parent.prototype;
|
2099
|
+
return child;
|
2100
|
+
};
|
2101
|
+
|
2102
|
+
Node = require('./node');
|
2103
|
+
|
2104
|
+
whitespace = require('../util/text').whitespace;
|
2105
|
+
|
2106
|
+
unescapeQuotes = require('../util/text').unescapeQuotes;
|
2107
|
+
|
2108
|
+
module.exports = Filter = (function (_super) {
|
2109
|
+
__extends(Filter, _super);
|
2110
|
+
|
2111
|
+
function Filter() {
|
2112
|
+
_ref = Filter.__super__.constructor.apply(this, arguments);
|
2113
|
+
return _ref;
|
2114
|
+
}
|
2115
|
+
|
2116
|
+
Filter.prototype.evaluate = function () {
|
2117
|
+
var _ref1;
|
2118
|
+
return this.filter = (_ref1 =
|
2119
|
+
this.expression.match(/:(escaped|preserve|css|javascript|coffeescript|plain|cdata|coffeescript)(.*)?/)) !=
|
2120
|
+
null ? _ref1[1] : void 0;
|
2121
|
+
};
|
2122
|
+
|
2123
|
+
Filter.prototype.render = function () {
|
2124
|
+
var child, indent, output, preserve, _i, _j, _len, _len1, _ref1, _ref2;
|
2125
|
+
output = [];
|
2126
|
+
switch (this.filter) {
|
2127
|
+
case 'escaped':
|
2128
|
+
_ref1 = this.children;
|
2129
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
2130
|
+
child = _ref1[_i];
|
2131
|
+
output.push(this.markText(child.render()[0].text, true));
|
2132
|
+
}
|
2133
|
+
break;
|
2134
|
+
case 'preserve':
|
2135
|
+
preserve = '';
|
2136
|
+
_ref2 = this.children;
|
2137
|
+
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
2138
|
+
child = _ref2[_j];
|
2139
|
+
preserve += "" + (child.render()[0].text) + "
";
|
2140
|
+
}
|
2141
|
+
preserve = preserve.replace(/\&\#x000A;$/, '');
|
2142
|
+
output.push(this.markText(preserve));
|
2143
|
+
break;
|
2144
|
+
case 'plain':
|
2145
|
+
this.renderFilterContent(0, output);
|
2146
|
+
break;
|
2147
|
+
case 'css':
|
2148
|
+
if (this.format === 'html5') {
|
2149
|
+
output.push(this.markText('<style>'));
|
2150
|
+
} else {
|
2151
|
+
output.push(this.markText('<style type=\'text/css\'>'));
|
2152
|
+
}
|
2153
|
+
if (this.format === 'xhtml') {
|
2154
|
+
output.push(this.markText(' /*<![CDATA[*/'));
|
2155
|
+
}
|
2156
|
+
indent = this.format === 'xhtml' ? 2 : 1;
|
2157
|
+
this.renderFilterContent(indent, output);
|
2158
|
+
if (this.format === 'xhtml') {
|
2159
|
+
output.push(this.markText(' /*]]>*/'));
|
2160
|
+
}
|
2161
|
+
output.push(this.markText('</style>'));
|
2162
|
+
break;
|
2163
|
+
case 'javascript':
|
2164
|
+
if (this.format === 'html5') {
|
2165
|
+
output.push(this.markText('<script>'));
|
2166
|
+
} else {
|
2167
|
+
output.push(this.markText('<script type=\'text/javascript\'>'));
|
2168
|
+
}
|
2169
|
+
if (this.format === 'xhtml') {
|
2170
|
+
output.push(this.markText(' //<![CDATA['));
|
2171
|
+
}
|
2172
|
+
indent = this.format === 'xhtml' ? 2 : 1;
|
2173
|
+
this.renderFilterContent(indent, output);
|
2174
|
+
if (this.format === 'xhtml') {
|
2175
|
+
output.push(this.markText(' //]]>'));
|
2176
|
+
}
|
2177
|
+
output.push(this.markText('</script>'));
|
2178
|
+
break;
|
2179
|
+
case 'cdata':
|
2180
|
+
output.push(this.markText('<![CDATA['));
|
2181
|
+
this.renderFilterContent(2, output);
|
2182
|
+
output.push(this.markText(']]>'));
|
2183
|
+
break;
|
2184
|
+
case 'coffeescript':
|
2185
|
+
this.renderFilterContent(0, output, 'run');
|
2186
|
+
}
|
2187
|
+
return output;
|
2188
|
+
};
|
2189
|
+
|
2190
|
+
Filter.prototype.renderFilterContent = function (indent, output, type) {
|
2191
|
+
var child, content, e, empty, line, _i, _j, _k, _len, _len1, _ref1, _results;
|
2192
|
+
if (type == null) {
|
2193
|
+
type = 'text';
|
2194
|
+
}
|
2195
|
+
content = [];
|
2196
|
+
empty = 0;
|
2197
|
+
_ref1 = this.children;
|
2198
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
2199
|
+
child = _ref1[_i];
|
2200
|
+
content.push(child.render()[0].text);
|
2201
|
+
}
|
2202
|
+
_results = [];
|
2203
|
+
for (_j = 0, _len1 = content.length; _j < _len1; _j++) {
|
2204
|
+
line = content[_j];
|
2205
|
+
if (line === '') {
|
2206
|
+
_results.push(empty += 1);
|
2207
|
+
} else {
|
2208
|
+
switch (type) {
|
2209
|
+
case 'text':
|
2210
|
+
for (e = _k = 0; 0 <= empty ? _k < empty : _k > empty; e = 0 <= empty ? ++_k : --_k) {
|
2211
|
+
output.push(this.markText(""));
|
2212
|
+
}
|
2213
|
+
output.push(this.markText("" + (whitespace(indent)) + line));
|
2214
|
+
break;
|
2215
|
+
case 'run':
|
2216
|
+
output.push(this.markRunningCode("" + (unescapeQuotes(line))));
|
2217
|
+
}
|
2218
|
+
_results.push(empty = 0);
|
2219
|
+
}
|
2220
|
+
}
|
2221
|
+
return _results;
|
2222
|
+
};
|
2223
|
+
|
2224
|
+
return Filter;
|
2225
|
+
|
2226
|
+
})(Node);
|
2227
|
+
|
2228
|
+
}).call(this);
|
2229
|
+
|
2230
|
+
});
|
2231
|
+
|
2232
|
+
require.define("/nodes/directive.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
2233
|
+
(function () {
|
2234
|
+
var CoffeeScript, Directive, Node, fs, path, _ref,
|
2235
|
+
__hasProp = {}.hasOwnProperty,
|
2236
|
+
__extends = function (child, parent) {
|
2237
|
+
for (var key in parent) {
|
2238
|
+
if (__hasProp.call(parent, key)) child[key] = parent[key];
|
2239
|
+
}
|
2240
|
+
function ctor() {
|
2241
|
+
this.constructor = child;
|
2242
|
+
}
|
2243
|
+
|
2244
|
+
ctor.prototype = parent.prototype;
|
2245
|
+
child.prototype = new ctor();
|
2246
|
+
child.__super__ = parent.prototype;
|
2247
|
+
return child;
|
2248
|
+
};
|
2249
|
+
|
2250
|
+
path = require('path');
|
2251
|
+
|
2252
|
+
Node = require('./node');
|
2253
|
+
|
2254
|
+
if (!process.browser) {
|
2255
|
+
fs = require('fs');
|
2256
|
+
CoffeeScript = require('coffee-script');
|
2257
|
+
}
|
2258
|
+
|
2259
|
+
module.exports = Directive = (function (_super) {
|
2260
|
+
__extends(Directive, _super);
|
2261
|
+
|
2262
|
+
function Directive() {
|
2263
|
+
_ref = Directive.__super__.constructor.apply(this, arguments);
|
2264
|
+
return _ref;
|
2265
|
+
}
|
2266
|
+
|
2267
|
+
Directive.prototype.directives = {
|
2268
|
+
include: function (expression) {
|
2269
|
+
var Compiler, code, compiler, context, e, error, name, source, statement, _ref1;
|
2270
|
+
try {
|
2271
|
+
_ref1 = expression.match(/\s*['"](.*?)['"](?:,\s*(.*))?\s*/), _ref1[0], name =
|
2272
|
+
_ref1[1], context = _ref1[2];
|
2273
|
+
} catch (_error) {
|
2274
|
+
e = _error;
|
2275
|
+
throw new Error("Failed to parse the include directive from " + expression);
|
2276
|
+
}
|
2277
|
+
if (!context) {
|
2278
|
+
context = 'this';
|
2279
|
+
}
|
2280
|
+
statement = (function () {
|
2281
|
+
switch (this.placement) {
|
2282
|
+
case 'global':
|
2283
|
+
return "" + this.namespace + "['" + name + "'](" + context + ")";
|
2284
|
+
case 'amd':
|
2285
|
+
return "require('" + name + "')(" + context + ")";
|
2286
|
+
case 'standalone':
|
2287
|
+
if (typeof browser !== "undefined" && browser !== null ? browser.process : void 0) {
|
2288
|
+
throw new Error("Include directive not available in the Browser when placement is standalone.");
|
2289
|
+
} else {
|
2290
|
+
try {
|
2291
|
+
source = fs.readFileSync(name).toString();
|
2292
|
+
} catch (_error) {
|
2293
|
+
error = _error;
|
2294
|
+
console.error(" Error opening file: %s", error);
|
2295
|
+
console.error(error);
|
2296
|
+
}
|
2297
|
+
Compiler = require('../haml-coffee');
|
2298
|
+
compiler = new Compiler(this.options);
|
2299
|
+
compiler.parse(source);
|
2300
|
+
code = CoffeeScript.compile(compiler.precompile(), {
|
2301
|
+
bare: true
|
2302
|
+
});
|
2303
|
+
return statement = "`(function(){" + code + "}).apply(" + context + ")`";
|
2304
|
+
}
|
2305
|
+
break;
|
2306
|
+
default:
|
2307
|
+
throw new Error("Include directive not available when placement is " + this.placement);
|
2308
|
+
}
|
2309
|
+
}).call(this);
|
2310
|
+
return this.opener = this.markInsertingCode(statement, false);
|
2311
|
+
}
|
2312
|
+
};
|
2313
|
+
|
2314
|
+
Directive.prototype.evaluate = function () {
|
2315
|
+
var directives, e, name, rest, _ref1;
|
2316
|
+
directives = Object.keys(this.directives).join('|');
|
2317
|
+
try {
|
2318
|
+
_ref1 = this.expression.match(RegExp("\\+(" + directives + ")(.*)")), _ref1[0], name =
|
2319
|
+
_ref1[1], rest = _ref1[2];
|
2320
|
+
} catch (_error) {
|
2321
|
+
e = _error;
|
2322
|
+
throw new Error("Unable to recognize directive from " + this.expression);
|
2323
|
+
}
|
2324
|
+
return this.directives[name].call(this, rest);
|
2325
|
+
};
|
2326
|
+
|
2327
|
+
return Directive;
|
2328
|
+
|
2329
|
+
})(Node);
|
2330
|
+
|
2331
|
+
}).call(this);
|
2332
|
+
|
2333
|
+
});
|
2334
|
+
|
2335
|
+
require.define("fs", function (require, module, exports, __dirname, __filename, process, global) {// nothing to see here... no file methods for the browser
|
2336
|
+
|
2337
|
+
});
|
2338
|
+
|
2339
|
+
require.define("/hamlc.coffee", function (require, module, exports, __dirname, __filename, process, global) {
|
2340
|
+
(function () {
|
2341
|
+
var CoffeeScript, Compiler, fs, __expressCache;
|
2342
|
+
|
2343
|
+
fs = require('fs');
|
2344
|
+
|
2345
|
+
Compiler = require('./haml-coffee');
|
2346
|
+
|
2347
|
+
if (process.browser) {
|
2348
|
+
CoffeeScript = window.CoffeeScript;
|
2349
|
+
} else {
|
2350
|
+
CoffeeScript = require('coffee-script');
|
2351
|
+
}
|
2352
|
+
|
2353
|
+
__expressCache = {};
|
2354
|
+
|
2355
|
+
module.exports = {
|
2356
|
+
render: function (source, context, options) {
|
2357
|
+
var compiler, template;
|
2358
|
+
if (context == null) {
|
2359
|
+
context = {};
|
2360
|
+
}
|
2361
|
+
if (options == null) {
|
2362
|
+
options = {};
|
2363
|
+
}
|
2364
|
+
options.placement = 'standalone';
|
2365
|
+
compiler = new Compiler(options);
|
2366
|
+
compiler.parse(source);
|
2367
|
+
template = new Function(CoffeeScript.compile(compiler.precompile(), {
|
2368
|
+
bare: true
|
2369
|
+
}));
|
2370
|
+
return template.call(context);
|
2371
|
+
},
|
2372
|
+
compile: function (source, options) {
|
2373
|
+
var compiler, template;
|
2374
|
+
if (options == null) {
|
2375
|
+
options = {};
|
2376
|
+
}
|
2377
|
+
compiler = new Compiler(options);
|
2378
|
+
compiler.parse(source);
|
2379
|
+
template = new Function(CoffeeScript.compile(compiler.precompile(), {
|
2380
|
+
bare: true
|
2381
|
+
}));
|
2382
|
+
return function (params) {
|
2383
|
+
return template.call(params);
|
2384
|
+
};
|
2385
|
+
},
|
2386
|
+
template: function (source, name, namespace, options) {
|
2387
|
+
var compiler;
|
2388
|
+
if (options == null) {
|
2389
|
+
options = {};
|
2390
|
+
}
|
2391
|
+
options.namespace = namespace;
|
2392
|
+
options.name = name;
|
2393
|
+
compiler = new Compiler(options);
|
2394
|
+
compiler.parse(source);
|
2395
|
+
return CoffeeScript.compile(compiler.render());
|
2396
|
+
},
|
2397
|
+
__express: function (filename, options, callback) {
|
2398
|
+
var err, source;
|
2399
|
+
if (!!(options && options.constructor && options.call && options.apply)) {
|
2400
|
+
callback = options;
|
2401
|
+
options = {};
|
2402
|
+
}
|
2403
|
+
try {
|
2404
|
+
if (options.cache && __expressCache[filename]) {
|
2405
|
+
return callback(null, __expressCache[filename](options));
|
2406
|
+
} else {
|
2407
|
+
options.filename = filename;
|
2408
|
+
source = fs.readFileSync(filename, 'utf8');
|
2409
|
+
if (options.cache) {
|
2410
|
+
__expressCache[filename] = module.exports.compile(source, options);
|
2411
|
+
return callback(null, __expressCache[filename](options));
|
2412
|
+
} else {
|
2413
|
+
return callback(null, module.exports.compile(source, options)(options));
|
2414
|
+
}
|
2415
|
+
}
|
2416
|
+
} catch (_error) {
|
2417
|
+
err = _error;
|
2418
|
+
return callback(err);
|
2419
|
+
}
|
2420
|
+
}
|
2421
|
+
};
|
2422
|
+
|
2423
|
+
}).call(this);
|
2424
|
+
|
2425
|
+
});
|
2426
|
+
|
2427
|
+
HamlCoffeeCompiler = require('./haml-coffee');
|
2428
|
+
|
2429
|
+
function compile(source, options) {
|
2430
|
+
var compiler = new HamlCoffeeCompiler(options);
|
2431
|
+
compiler.parse(source);
|
2432
|
+
return compiler.precompile();
|
2433
|
+
}
|