haml_coffee_assets 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +13 -84
- data/lib/haml_coffee_assets/engine.rb +6 -0
- data/lib/haml_coffee_assets/haml_coffee.rb +18 -1
- data/lib/haml_coffee_assets/haml_coffee_assets.js +7 -0
- data/lib/haml_coffee_assets/haml_coffee_template.rb +1 -1
- data/lib/haml_coffee_assets/version.rb +1 -1
- data/lib/js/haml-coffee.js +88 -51
- data/vendor/assets/javascripts/hamlcoffee.js.coffee.erb +31 -0
- metadata +36 -36
data/README.md
CHANGED
@@ -295,90 +295,19 @@ config.hamlcoffee.autoclose = 'meta,img,link,br,hr,input,area,param,col,base'
|
|
295
295
|
|
296
296
|
Haml Coffee Assets provides a set of custom functions for Haml Coffee, so that the templates doesn't have to be self
|
297
297
|
contained and can make use of the global functions. In general you don't have to customize them further, but if you need
|
298
|
-
to, you can
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
Your custom escape function must take the unescaped text as parameter and returns the escaped text.
|
312
|
-
The following default implementation comes with `hamlcoffee.js`:
|
313
|
-
|
314
|
-
```coffeescript
|
315
|
-
App.myEscape = (text) ->
|
316
|
-
('' + text)
|
317
|
-
.replace(/&/g, '&')
|
318
|
-
.replace(/</g, '<')
|
319
|
-
.replace(/>/g, '>')
|
320
|
-
.replace(/'/g, ''')
|
321
|
-
.replace(/"/g, '"')
|
322
|
-
```
|
323
|
-
|
324
|
-
#### Custom clean value function
|
325
|
-
|
326
|
-
All your evaluated CoffeeScript code will go through the clean value function. By default this simply cleans `undefined`
|
327
|
-
and `null` values, so that they appear as empty string in your template.
|
328
|
-
|
329
|
-
You can set a custom clean value function in your `config/application.rb`:
|
330
|
-
|
331
|
-
```ruby
|
332
|
-
config.hamlcoffee.customCleanValue = 'App.myCleanValue'
|
333
|
-
```
|
334
|
-
|
335
|
-
Your custom clean value function must take the value as parameter and returns the cleaned value.
|
336
|
-
The following default implementation comes with `hamlcoffee.js`:
|
337
|
-
|
338
|
-
```coffeescript
|
339
|
-
App.myCleanValue = (value) -> if value is null or value is undefined then '' else value
|
340
|
-
```
|
341
|
-
|
342
|
-
#### Custom preserve function
|
343
|
-
|
344
|
-
All the content from the HTML tags that are contained in the whitespace sensitive tag list are passed through the
|
345
|
-
preserve function.
|
346
|
-
|
347
|
-
You can set a custom preserve function in your `config/application.rb`:
|
348
|
-
|
349
|
-
```ruby
|
350
|
-
config.hamlcoffee.customPreserve = 'App.myPreserve'
|
351
|
-
```
|
352
|
-
|
353
|
-
Your custom preserve function must take the text to be preserved as parameter and returns the preserved content.
|
354
|
-
The following default implementation comes with `hamlcoffee.js`:
|
355
|
-
|
356
|
-
```coffeescript
|
357
|
-
App.myPreserve = (value) -> text.replace /\\n/g, '
'
|
358
|
-
```
|
359
|
-
|
360
|
-
#### Custom find and preserve function
|
361
|
-
|
362
|
-
The findAndPreserve function is a specialized preserve function, that you can pass a text containing HTML, and only the
|
363
|
-
newlines in between a whitespace sensitive tag are preserved. This function uses the previous preserve function to do
|
364
|
-
the final preservation.
|
365
|
-
|
366
|
-
You can set a custom find and preserve function in your `config/application.rb`:
|
367
|
-
|
368
|
-
```ruby
|
369
|
-
config.hamlcoffee.customFindAndPreserve = 'App.myFindAndPreserve'
|
370
|
-
```
|
371
|
-
|
372
|
-
Your custom find and preserve function must take the text to search for whitespace sensitive tags as parameter and
|
373
|
-
returns the preserved content.
|
374
|
-
|
375
|
-
The following default implementation comes with `hamlcoffee.js`:
|
376
|
-
|
377
|
-
```coffeescript
|
378
|
-
App.myPreserve = (value) ->
|
379
|
-
text.replace /<(textarea|pre)>([^]*?)<\/\1>/g, (str, tag, content) ->
|
380
|
-
"<#{ tag }>#{ HAML.preserve(content) }</#{ tag }>"
|
381
|
-
```
|
298
|
+
to, you can set custom functions for:
|
299
|
+
|
300
|
+
* config.hamlcoffee.customHtmlEscape
|
301
|
+
* config.hamlcoffee.customCleanValue
|
302
|
+
* config.hamlcoffee.customPreserve
|
303
|
+
* config.hamlcoffee.customFindAndPreserve
|
304
|
+
* config.hamlcoffee.customSurround
|
305
|
+
* config.hamlcoffee.customSucceed
|
306
|
+
* config.hamlcoffee.customPrecede
|
307
|
+
|
308
|
+
You can see the [default implementation](https://github.com/netzpirat/haml_coffee_assets/blob/master/vendor/assets/javascripts/hamlcoffee.js.coffee.erb)
|
309
|
+
and the [Haml Coffee documentation](https://github.com/9elements/haml-coffee#custom-helper-function-compiler-options)
|
310
|
+
for more information about each helper function.
|
382
311
|
|
383
312
|
## Development
|
384
313
|
|
@@ -20,6 +20,9 @@ module HamlCoffeeAssets
|
|
20
20
|
:customCleanValue => 'HAML.cleanValue',
|
21
21
|
:customPreserve => 'HAML.escape',
|
22
22
|
:customFindAndPreserve => 'HAML.findAndPreserve',
|
23
|
+
:customSurround => 'HAML.surround',
|
24
|
+
:customSucceed => 'HAML.succeed',
|
25
|
+
:customPrecede => 'HAML.precede',
|
23
26
|
:preserve => 'textarea,pre',
|
24
27
|
:autoclose => 'meta,img,link,br,hr,input,area,param,col,base',
|
25
28
|
:context => 'HAML.context'
|
@@ -48,6 +51,9 @@ module HamlCoffeeAssets
|
|
48
51
|
config.customCleanValue = options[:customCleanValue]
|
49
52
|
config.customPreserve = options[:customPreserve]
|
50
53
|
config.customFindAndPreserve = options[:customFindAndPreserve]
|
54
|
+
config.customPreserve = options[:customSurround]
|
55
|
+
config.customSucceed = options[:customSucceed]
|
56
|
+
config.customPrecede = options[:customPrecede]
|
51
57
|
config.preserveTags = options[:preserve]
|
52
58
|
config.selfCloseTags = options[:autoclose]
|
53
59
|
config.context = options[:context]
|
@@ -21,6 +21,9 @@ module HamlCoffeeAssets
|
|
21
21
|
self.customCleanValue = 'window.HAML.cleanValue'
|
22
22
|
self.customPreserve = 'window.HAML.preserve'
|
23
23
|
self.customFindAndPreserve = 'window.HAML.findAndPreserve'
|
24
|
+
self.customSurround = 'window.HAML.surround'
|
25
|
+
self.customSucceed = 'window.HAML.succeed'
|
26
|
+
self.customPrecede = 'window.HAML.precede'
|
24
27
|
self.preserveTags = 'textarea,pre'
|
25
28
|
self.selfCloseTags = 'meta,img,link,br,hr,input,area,param,col,base'
|
26
29
|
self.context = ''
|
@@ -62,6 +65,18 @@ module HamlCoffeeAssets
|
|
62
65
|
#
|
63
66
|
attr_accessor :customCleanValue
|
64
67
|
|
68
|
+
# Custom global surround function
|
69
|
+
#
|
70
|
+
attr_accessor :customSurround
|
71
|
+
|
72
|
+
# Custom global succeed function
|
73
|
+
#
|
74
|
+
attr_accessor :customSucceed
|
75
|
+
|
76
|
+
# Custom global precede function
|
77
|
+
#
|
78
|
+
attr_accessor :customPrecede
|
79
|
+
|
65
80
|
# Custom preserve function
|
66
81
|
#
|
67
82
|
attr_accessor :customPreserve
|
@@ -104,10 +119,12 @@ module HamlCoffeeAssets
|
|
104
119
|
#
|
105
120
|
def compile(name, source, jst = true)
|
106
121
|
self.configuration ||= Configuration.new
|
107
|
-
runtime.call('HamlCoffeeAssets.compile', name, source, jst,
|
122
|
+
runtime.call('HamlCoffeeAssets.compile', name, source, jst,
|
123
|
+
configuration.namespace, configuration.format, configuration.uglify, configuration.basename,
|
108
124
|
configuration.escapeHtml, configuration.escapeAttributes, configuration.cleanValue,
|
109
125
|
configuration.customHtmlEscape, configuration.customCleanValue,
|
110
126
|
configuration.customPreserve, configuration.customFindAndPreserve,
|
127
|
+
configuration.customSurround, configuration.customSucceed, configuration.customPrecede,
|
111
128
|
configuration.preserveTags, configuration.selfCloseTags,
|
112
129
|
configuration.context)
|
113
130
|
end
|
@@ -30,6 +30,9 @@ var HamlCoffeeAssets = (function(){
|
|
30
30
|
* @param escapeAttributes [Boolean] whether to escape HTML attributes output by default or not
|
31
31
|
* @param customHtmlEscape [String] the name of the function to escape the output
|
32
32
|
* @param customCleanValue [String] the name of the function to clean the code output
|
33
|
+
* @param customSurround [String] the name of the function for the surround helper
|
34
|
+
* @param customSucceed [String] the name of the function for the succeed helper
|
35
|
+
* @param customPrecede [String] the name of the function for the precede helper
|
33
36
|
* @param preserveTags [String] comma separated list of tags to preserve whitespace
|
34
37
|
* @param selfCloseTags [String] comma separated list of tags to self-closing tags
|
35
38
|
* @param context [String] the name of the function to merge contexts
|
@@ -37,6 +40,7 @@ var HamlCoffeeAssets = (function(){
|
|
37
40
|
compile: function(name, source, jst, namespace, format, uglify, basename,
|
38
41
|
escapeHtml, escapeAttributes, cleanValue,
|
39
42
|
customHtmlEscape, customCleanValue, customPreserve, customFindAndPreserve,
|
43
|
+
customSurround, customSucceed, customPrecede,
|
40
44
|
preserveTags, selfCloseTags,
|
41
45
|
context) {
|
42
46
|
|
@@ -51,6 +55,9 @@ var HamlCoffeeAssets = (function(){
|
|
51
55
|
customCleanValue: customCleanValue,
|
52
56
|
customPreserve: customPreserve,
|
53
57
|
customFindAndPreserve: customFindAndPreserve,
|
58
|
+
customSurround: customSurround,
|
59
|
+
customSucceed: customSucceed,
|
60
|
+
customPrecede: customPrecede,
|
54
61
|
preserveTags: preserveTags,
|
55
62
|
selfCloseTags: selfCloseTags
|
56
63
|
});
|
@@ -32,7 +32,7 @@ module HamlCoffeeAssets
|
|
32
32
|
# Compile the template.
|
33
33
|
#
|
34
34
|
def evaluate(scope, locals = { }, &block)
|
35
|
-
jst = scope.pathname.to_s =~ /\.jst\.hamlc
|
35
|
+
jst = scope.pathname.to_s =~ /\.jst\.hamlc(?:\.|$)/ ? false : true
|
36
36
|
@output ||= HamlCoffee.compile(scope.logical_path, data, jst)
|
37
37
|
end
|
38
38
|
|
data/lib/js/haml-coffee.js
CHANGED
@@ -342,28 +342,20 @@ require.define("/haml-coffee.js", function (require, module, exports, __dirname,
|
|
342
342
|
module.exports = HamlCoffee = (function() {
|
343
343
|
|
344
344
|
function HamlCoffee(options) {
|
345
|
-
var _base, _base2, _base3, _base4, _base5, _base6, _base7, _base8
|
345
|
+
var _base, _base2, _base3, _base4, _base5, _base6, _base7, _base8;
|
346
346
|
this.options = options != null ? options : {};
|
347
|
-
if ((
|
348
|
-
|
349
|
-
}
|
350
|
-
if ((_ref2 = (_base2 = this.options).escapeAttributes) == null) {
|
347
|
+
if ((_base = this.options).escapeHtml == null) _base.escapeHtml = true;
|
348
|
+
if ((_base2 = this.options).escapeAttributes == null) {
|
351
349
|
_base2.escapeAttributes = true;
|
352
350
|
}
|
353
|
-
if ((
|
354
|
-
|
355
|
-
|
356
|
-
if ((
|
357
|
-
if ((
|
358
|
-
_base5.basename = false;
|
359
|
-
}
|
360
|
-
if ((_ref6 = (_base6 = this.options).format) == null) {
|
361
|
-
_base6.format = 'html5';
|
362
|
-
}
|
363
|
-
if ((_ref7 = (_base7 = this.options).preserveTags) == null) {
|
351
|
+
if ((_base3 = this.options).cleanValue == null) _base3.cleanValue = true;
|
352
|
+
if ((_base4 = this.options).uglify == null) _base4.uglify = false;
|
353
|
+
if ((_base5 = this.options).basename == null) _base5.basename = false;
|
354
|
+
if ((_base6 = this.options).format == null) _base6.format = 'html5';
|
355
|
+
if ((_base7 = this.options).preserveTags == null) {
|
364
356
|
_base7.preserveTags = 'pre,textarea';
|
365
357
|
}
|
366
|
-
if ((
|
358
|
+
if ((_base8 = this.options).selfCloseTags == null) {
|
367
359
|
_base8.selfCloseTags = 'meta,img,link,br,hr,input,area,param,col,base';
|
368
360
|
}
|
369
361
|
}
|
@@ -495,7 +487,7 @@ require.define("/haml-coffee.js", function (require, module, exports, __dirname,
|
|
495
487
|
ws = result[1];
|
496
488
|
expression = result[2];
|
497
489
|
if (/^(\s)*$/.test(line)) continue;
|
498
|
-
while (/^%.*[{(]/.test(expression) && !/^(\s*)[-=&!~.%#<]/.test(lines[0]) && /(?:(
|
490
|
+
while (/^%.*[{(]/.test(expression) && !/^(\s*)[-=&!~.%#<]/.test(lines[0]) && /(?:([-\w]+[\w:-]*\w?|'[-\w]+[\w:-]*\w?'|"[-\w]+[\w:-]*\w?")\s*=\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[\w@.]+)|(:\w+[\w:-]*\w?|'[-\w]+[\w:-]*\w?'|"[-\w]+[\w:-]*\w?")\s*=>\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^},]+)|(\w+[\w:-]*\w?|'[-\w]+[\w:-]*\w?'|'[-\w]+[\w:-]*\w?'):\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^},]+))/.test(lines[0])) {
|
499
491
|
attributes = lines.shift();
|
500
492
|
expression += ' ' + attributes.match(/^(\s*)(.*)/)[2];
|
501
493
|
this.line_number++;
|
@@ -587,6 +579,27 @@ require.define("/haml-coffee.js", function (require, module, exports, __dirname,
|
|
587
579
|
fn += "$fp = (text) ->\n text.replace /<(" + (this.options.preserveTags.split(',').join('|')) + ")>([^]*?)<\\/\\1>/g, (str, tag, content) ->\n \"<\#{ tag }>\#{ $p content }</\#{ tag }>\"\n";
|
588
580
|
}
|
589
581
|
}
|
582
|
+
if (code.indexOf('surround') !== -1) {
|
583
|
+
if (this.options.customSurround) {
|
584
|
+
fn += "surround = " + this.options.customSurround + "\n";
|
585
|
+
} else {
|
586
|
+
fn += "surround = (start, end, fn) -> start + fn() + end\n";
|
587
|
+
}
|
588
|
+
}
|
589
|
+
if (code.indexOf('succeed') !== -1) {
|
590
|
+
if (this.options.customSucceed) {
|
591
|
+
fn += "succeed = " + this.options.customSucceed + "\n";
|
592
|
+
} else {
|
593
|
+
fn += "succeed = (end, fn) -> fn() + end\n";
|
594
|
+
}
|
595
|
+
}
|
596
|
+
if (code.indexOf('precede') !== -1) {
|
597
|
+
if (this.options.customPrecede) {
|
598
|
+
fn += "precede = " + this.options.customPrecede + "\n";
|
599
|
+
} else {
|
600
|
+
fn += "precede = (start, fn) -> start + fn()\n";
|
601
|
+
}
|
602
|
+
}
|
590
603
|
fn += "$o = []\n";
|
591
604
|
fn += "" + code + "\n";
|
592
605
|
return fn += "return $o.join(\"\\n\")" + (this.convertBooleans(code)) + (this.cleanupWhitespace(code)) + "\n";
|
@@ -602,16 +615,22 @@ require.define("/haml-coffee.js", function (require, module, exports, __dirname,
|
|
602
615
|
this.lines = this.lines.concat(child.render());
|
603
616
|
}
|
604
617
|
this.lines = this.combineText(this.lines);
|
618
|
+
this.block = false;
|
605
619
|
_ref2 = this.lines;
|
606
620
|
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
|
607
621
|
line = _ref2[_j];
|
608
622
|
if (line !== null) {
|
609
623
|
switch (line.type) {
|
610
624
|
case 'text':
|
611
|
-
|
625
|
+
if (this.block) {
|
626
|
+
code.push("" + (whitespace(line.cw)) + "$b.push \"" + (whitespace(line.hw)) + line.text + "\"");
|
627
|
+
} else {
|
628
|
+
code.push("" + (whitespace(line.cw)) + "$o.push \"" + (whitespace(line.hw)) + line.text + "\"");
|
629
|
+
}
|
612
630
|
break;
|
613
631
|
case 'run':
|
614
632
|
code.push("" + (whitespace(line.cw)) + line.code);
|
633
|
+
if (line.block === 'end') this.block = false;
|
615
634
|
break;
|
616
635
|
case 'insert':
|
617
636
|
processors = '';
|
@@ -620,6 +639,10 @@ require.define("/haml-coffee.js", function (require, module, exports, __dirname,
|
|
620
639
|
if (line.escape) processors += '$e ';
|
621
640
|
if (this.options.cleanValue) processors += '$c ';
|
622
641
|
code.push("" + (whitespace(line.cw)) + "$o.push \"" + (whitespace(line.hw)) + "\" + " + processors + line.code);
|
642
|
+
if (line.block === 'start') {
|
643
|
+
this.block = true;
|
644
|
+
code.push("" + (whitespace(line.cw + 1)) + "$b = []");
|
645
|
+
}
|
623
646
|
}
|
624
647
|
}
|
625
648
|
}
|
@@ -837,7 +860,8 @@ require.define("/nodes/node.js", function (require, module, exports, __dirname,
|
|
837
860
|
});
|
838
861
|
|
839
862
|
require.define("/util/text.js", function (require, module, exports, __dirname, __filename) {
|
840
|
-
|
863
|
+
(function() {
|
864
|
+
|
841
865
|
module.exports = {
|
842
866
|
whitespace: function(n) {
|
843
867
|
var a;
|
@@ -868,20 +892,23 @@ require.define("/util/text.js", function (require, module, exports, __dirname, _
|
|
868
892
|
}
|
869
893
|
};
|
870
894
|
|
895
|
+
}).call(this);
|
896
|
+
|
871
897
|
});
|
872
898
|
|
873
899
|
require.define("/nodes/text.js", function (require, module, exports, __dirname, __filename) {
|
874
900
|
(function() {
|
875
|
-
var Node, Text, escapeQuotes
|
876
|
-
|
901
|
+
var Node, Text, escapeQuotes,
|
902
|
+
__hasProp = Object.prototype.hasOwnProperty,
|
903
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
|
877
904
|
|
878
905
|
Node = require('./node');
|
879
906
|
|
880
907
|
escapeQuotes = require('../util/text').escapeQuotes;
|
881
908
|
|
882
|
-
module.exports = Text = (function() {
|
909
|
+
module.exports = Text = (function(_super) {
|
883
910
|
|
884
|
-
__extends(Text,
|
911
|
+
__extends(Text, _super);
|
885
912
|
|
886
913
|
function Text() {
|
887
914
|
Text.__super__.constructor.apply(this, arguments);
|
@@ -893,7 +920,7 @@ require.define("/nodes/text.js", function (require, module, exports, __dirname,
|
|
893
920
|
|
894
921
|
return Text;
|
895
922
|
|
896
|
-
})();
|
923
|
+
})(Node);
|
897
924
|
|
898
925
|
}).call(this);
|
899
926
|
|
@@ -901,16 +928,17 @@ require.define("/nodes/text.js", function (require, module, exports, __dirname,
|
|
901
928
|
|
902
929
|
require.define("/nodes/haml.js", function (require, module, exports, __dirname, __filename) {
|
903
930
|
(function() {
|
904
|
-
var Haml, Node, escapeQuotes
|
905
|
-
|
931
|
+
var Haml, Node, escapeQuotes,
|
932
|
+
__hasProp = Object.prototype.hasOwnProperty,
|
933
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
|
906
934
|
|
907
935
|
Node = require('./node');
|
908
936
|
|
909
937
|
escapeQuotes = require('../util/text').escapeQuotes;
|
910
938
|
|
911
|
-
module.exports = Haml = (function() {
|
939
|
+
module.exports = Haml = (function(_super) {
|
912
940
|
|
913
|
-
__extends(Haml,
|
941
|
+
__extends(Haml, _super);
|
914
942
|
|
915
943
|
function Haml() {
|
916
944
|
Haml.__super__.constructor.apply(this, arguments);
|
@@ -1074,7 +1102,7 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
|
|
1074
1102
|
attributes = [];
|
1075
1103
|
if (exp === void 0) return attributes;
|
1076
1104
|
_ref = this.getDataAttributes(exp), exp = _ref[0], datas = _ref[1];
|
1077
|
-
findAttributes = /(?:(
|
1105
|
+
findAttributes = /(?:([-\w]+[\w:-]*\w?|'\w+[\w:-]*\w?'|"\w+[\w:-]*\w?")\s*=\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[\w@.]+)|(:\w+[\w:-]*\w?|'[-\w]+[\w:-]*\w?'|"[-\w]+[\w:-]*\w?")\s*=>\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^},]+)|(\w+[\w:-]*\w?|'[-\w]+[\w:-]*\w?'|"[-\w]+[\w:-]*\w?"):\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^},]+))/g;
|
1078
1106
|
while (match = findAttributes.exec(exp)) {
|
1079
1107
|
key = (match[1] || match[3] || match[5]).replace(/^:/, '');
|
1080
1108
|
value = match[2] || match[4] || match[6];
|
@@ -1203,7 +1231,7 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
|
|
1203
1231
|
|
1204
1232
|
return Haml;
|
1205
1233
|
|
1206
|
-
})();
|
1234
|
+
})(Node);
|
1207
1235
|
|
1208
1236
|
}).call(this);
|
1209
1237
|
|
@@ -1211,21 +1239,22 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
|
|
1211
1239
|
|
1212
1240
|
require.define("/nodes/code.js", function (require, module, exports, __dirname, __filename) {
|
1213
1241
|
(function() {
|
1214
|
-
var Code, Node
|
1215
|
-
|
1242
|
+
var Code, Node,
|
1243
|
+
__hasProp = Object.prototype.hasOwnProperty,
|
1244
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
|
1216
1245
|
|
1217
1246
|
Node = require('./node');
|
1218
1247
|
|
1219
|
-
module.exports = Code = (function() {
|
1248
|
+
module.exports = Code = (function(_super) {
|
1220
1249
|
|
1221
|
-
__extends(Code,
|
1250
|
+
__extends(Code, _super);
|
1222
1251
|
|
1223
1252
|
function Code() {
|
1224
1253
|
Code.__super__.constructor.apply(this, arguments);
|
1225
1254
|
}
|
1226
1255
|
|
1227
1256
|
Code.prototype.evaluate = function() {
|
1228
|
-
var code, codeBlock, identifier;
|
1257
|
+
var code, codeBlock, escape, identifier;
|
1229
1258
|
codeBlock = this.expression.match(/(-|!=|\&=|=|~)\s?(.*)?/);
|
1230
1259
|
identifier = codeBlock[1];
|
1231
1260
|
code = codeBlock[2];
|
@@ -1240,16 +1269,22 @@ require.define("/nodes/code.js", function (require, module, exports, __dirname,
|
|
1240
1269
|
} else {
|
1241
1270
|
return this.opener = this.markInsertingCode(code, false, false, true);
|
1242
1271
|
}
|
1243
|
-
} else
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1272
|
+
} else {
|
1273
|
+
escape = identifier === '&=' || (identifier === '=' && this.escapeHtml);
|
1274
|
+
if (this.children.length !== 0 && code.match(/(->|=>)$/)) {
|
1275
|
+
this.opener = this.markInsertingCode(code, escape, false, false);
|
1276
|
+
this.opener.block = 'start';
|
1277
|
+
this.closer = this.markRunningCode(" $b.join \"\\n\"");
|
1278
|
+
return this.closer.block = 'end';
|
1279
|
+
} else {
|
1280
|
+
return this.opener = this.markInsertingCode(code, escape);
|
1281
|
+
}
|
1247
1282
|
}
|
1248
1283
|
};
|
1249
1284
|
|
1250
1285
|
return Code;
|
1251
1286
|
|
1252
|
-
})();
|
1287
|
+
})(Node);
|
1253
1288
|
|
1254
1289
|
}).call(this);
|
1255
1290
|
|
@@ -1257,14 +1292,15 @@ require.define("/nodes/code.js", function (require, module, exports, __dirname,
|
|
1257
1292
|
|
1258
1293
|
require.define("/nodes/comment.js", function (require, module, exports, __dirname, __filename) {
|
1259
1294
|
(function() {
|
1260
|
-
var Comment, Node
|
1261
|
-
|
1295
|
+
var Comment, Node,
|
1296
|
+
__hasProp = Object.prototype.hasOwnProperty,
|
1297
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
|
1262
1298
|
|
1263
1299
|
Node = require('./node');
|
1264
1300
|
|
1265
|
-
module.exports = Comment = (function() {
|
1301
|
+
module.exports = Comment = (function(_super) {
|
1266
1302
|
|
1267
|
-
__extends(Comment,
|
1303
|
+
__extends(Comment, _super);
|
1268
1304
|
|
1269
1305
|
function Comment() {
|
1270
1306
|
Comment.__super__.constructor.apply(this, arguments);
|
@@ -1293,7 +1329,7 @@ require.define("/nodes/comment.js", function (require, module, exports, __dirnam
|
|
1293
1329
|
|
1294
1330
|
return Comment;
|
1295
1331
|
|
1296
|
-
})();
|
1332
|
+
})(Node);
|
1297
1333
|
|
1298
1334
|
}).call(this);
|
1299
1335
|
|
@@ -1301,16 +1337,17 @@ require.define("/nodes/comment.js", function (require, module, exports, __dirnam
|
|
1301
1337
|
|
1302
1338
|
require.define("/nodes/filter.js", function (require, module, exports, __dirname, __filename) {
|
1303
1339
|
(function() {
|
1304
|
-
var Filter, Node, whitespace
|
1305
|
-
|
1340
|
+
var Filter, Node, whitespace,
|
1341
|
+
__hasProp = Object.prototype.hasOwnProperty,
|
1342
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
|
1306
1343
|
|
1307
1344
|
Node = require('./node');
|
1308
1345
|
|
1309
1346
|
whitespace = require('../util/text').whitespace;
|
1310
1347
|
|
1311
|
-
module.exports = Filter = (function() {
|
1348
|
+
module.exports = Filter = (function(_super) {
|
1312
1349
|
|
1313
|
-
__extends(Filter,
|
1350
|
+
__extends(Filter, _super);
|
1314
1351
|
|
1315
1352
|
function Filter() {
|
1316
1353
|
Filter.__super__.constructor.apply(this, arguments);
|
@@ -1416,7 +1453,7 @@ require.define("/nodes/filter.js", function (require, module, exports, __dirname
|
|
1416
1453
|
|
1417
1454
|
return Filter;
|
1418
1455
|
|
1419
|
-
})();
|
1456
|
+
})(Node);
|
1420
1457
|
|
1421
1458
|
}).call(this);
|
1422
1459
|
|
@@ -88,3 +88,34 @@ window.HAML.findAndPreserve ||= (text) ->
|
|
88
88
|
tags = '<%= configuration.preserveTags %>'.split(',').join('|')
|
89
89
|
text.replace ///<(#{ tags })>([^]*?)<\/\1>///g, (str, tag, content) ->
|
90
90
|
"<#{ tag }>#{ <%= configuration.customPreserve %>(content) }</#{ tag }>"
|
91
|
+
|
92
|
+
# The surround helper surrounds the function output
|
93
|
+
# with the start and end string without whitespace in between.
|
94
|
+
#
|
95
|
+
# @param [String] start the text to prepend to the text
|
96
|
+
# @param [String] end the text to append to the text
|
97
|
+
# @param [Function] fn the text generating function
|
98
|
+
# @return [String] the surrounded text
|
99
|
+
#
|
100
|
+
surround: (start, end, fn) ->
|
101
|
+
start + fn() + end
|
102
|
+
|
103
|
+
# The succeed helper appends text to the function output
|
104
|
+
# without whitespace in between.
|
105
|
+
#
|
106
|
+
# @param [String] end the text to append to the text
|
107
|
+
# @param [Function] fn the text generating function
|
108
|
+
# @return [String] the succeeded text
|
109
|
+
#
|
110
|
+
succeed: (end, fn) ->
|
111
|
+
fn() + end
|
112
|
+
|
113
|
+
# The precede helper prepends text to the function output
|
114
|
+
# without whitespace in between.
|
115
|
+
#
|
116
|
+
# @param [String] start the text to prepend to the text
|
117
|
+
# @param [Function] fn the text generating function
|
118
|
+
# @return [String] the preeceded text
|
119
|
+
#
|
120
|
+
precede: (start, fn) ->
|
121
|
+
start + fn()
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_coffee_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|
16
|
-
requirement: &
|
16
|
+
requirement: &70356011006040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.2.9
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70356011006040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tilt
|
27
|
-
requirement: &
|
27
|
+
requirement: &70356011005580 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.3.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70356011005580
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sprockets
|
38
|
-
requirement: &
|
38
|
+
requirement: &70356011005120 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.0.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70356011005120
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70356011004740 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70356011004740
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: railties
|
60
|
-
requirement: &
|
60
|
+
requirement: &70356011004200 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,73 +65,73 @@ dependencies:
|
|
65
65
|
version: '3.1'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70356011004200
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70356011003780 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ! '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70356011003780
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: guard-rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70356011037600 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - ! '>='
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: 0
|
87
|
+
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70356011037600
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: yard
|
93
|
-
requirement: &
|
93
|
+
requirement: &70356011037180 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ! '>='
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0
|
98
|
+
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70356011037180
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: redcarpet
|
104
|
-
requirement: &
|
104
|
+
requirement: &70356011036760 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70356011036760
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: pry
|
115
|
-
requirement: &
|
115
|
+
requirement: &70356011036340 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
|
-
- -
|
118
|
+
- - ! '>='
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: 0
|
120
|
+
version: '0'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70356011036340
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: rake
|
126
|
-
requirement: &
|
126
|
+
requirement: &70356011035920 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ! '>='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0
|
131
|
+
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70356011035920
|
135
135
|
description: Compile Haml CoffeeScript templates in the Rails asset pipeline.
|
136
136
|
email:
|
137
137
|
- michi@netzpiraten.ch
|