haml_coffee_assets 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/haml_coffee_assets/version.rb +1 -1
- data/lib/js/haml-coffee.js +33 -19
- metadata +3 -3
data/README.md
CHANGED
@@ -143,7 +143,7 @@ processor by using `.jst.hamlc` as extension, and if you do, the Haml Coffee tem
|
|
143
143
|
By default all Haml Coffee templates are rendered to a HTML5 document. You can choose between the following output
|
144
144
|
formats:
|
145
145
|
|
146
|
-
*
|
146
|
+
* html5
|
147
147
|
* html4
|
148
148
|
* xhtml
|
149
149
|
|
data/lib/js/haml-coffee.js
CHANGED
@@ -499,6 +499,13 @@ require.define("/helper.js", function (require, module, exports, __dirname, __fi
|
|
499
499
|
escapeHTML: function(text) {
|
500
500
|
if (!text) return '';
|
501
501
|
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"');
|
502
|
+
},
|
503
|
+
preserve: function(code) {
|
504
|
+
if (code) {
|
505
|
+
return code.replace(/<(pre|textarea)>(.*?)<\/\1>/g, function(text) {
|
506
|
+
return text.replace('\\n', '\&\#x000A;');
|
507
|
+
});
|
508
|
+
}
|
502
509
|
}
|
503
510
|
};
|
504
511
|
|
@@ -535,13 +542,15 @@ require.define("/nodes/text.js", function (require, module, exports, __dirname,
|
|
535
542
|
|
536
543
|
require.define("/nodes/haml.js", function (require, module, exports, __dirname, __filename) {
|
537
544
|
(function() {
|
538
|
-
var Haml, Node, eq;
|
545
|
+
var Haml, Node, eq, p;
|
539
546
|
var __hasProp = Object.prototype.hasOwnProperty, __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; };
|
540
547
|
|
541
548
|
Node = require('./node');
|
542
549
|
|
543
550
|
eq = require('../helper').escapeQuotes;
|
544
551
|
|
552
|
+
p = require('../helper').preserve;
|
553
|
+
|
545
554
|
module.exports = Haml = (function() {
|
546
555
|
|
547
556
|
__extends(Haml, Node);
|
@@ -555,7 +564,7 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
|
|
555
564
|
Haml.preserveTags = ['pre', 'textarea'];
|
556
565
|
|
557
566
|
Haml.prototype.evaluate = function() {
|
558
|
-
var code, prefix, tokens;
|
567
|
+
var assignment, code, identifier, match, prefix, tokens;
|
559
568
|
tokens = this.parseExpression(this.expression);
|
560
569
|
if (tokens.doctype) {
|
561
570
|
return this.opener = this.markText("" + (eq(this.buildDocType(tokens.doctype))));
|
@@ -563,7 +572,16 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
|
|
563
572
|
if (this.isNotSelfClosing(tokens.tag)) {
|
564
573
|
prefix = eq(this.buildHtmlTagPrefix(tokens));
|
565
574
|
if (tokens.assignment) {
|
566
|
-
|
575
|
+
match = tokens.assignment.match(/^(=|!=|&=|~)\s*(.*)$/);
|
576
|
+
identifier = match[1];
|
577
|
+
assignment = match[2];
|
578
|
+
if (identifier === '~') {
|
579
|
+
code = p(assignment);
|
580
|
+
} else if (identifier === '&=' || (identifier === '=' && this.escapeHtml)) {
|
581
|
+
code = "\#{e " + assignment + "}";
|
582
|
+
} else if (identifier === '!=' || (identifier === '=' && !this.escapeHtml)) {
|
583
|
+
code = "\#{" + assignment + "}";
|
584
|
+
}
|
567
585
|
this.opener = this.markText("" + prefix + ">" + code);
|
568
586
|
return this.closer = this.markText("</" + tokens.tag + ">");
|
569
587
|
} else if (tokens.text) {
|
@@ -618,7 +636,7 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
|
|
618
636
|
};
|
619
637
|
|
620
638
|
Haml.prototype.parseTag = function(exp) {
|
621
|
-
var assignment, attributes, classes, doctype, haml, id, ids, klass, tag, text, tokens, whitespace, _ref
|
639
|
+
var assignment, attributes, classes, doctype, haml, id, ids, klass, tag, text, tokens, whitespace, _ref;
|
622
640
|
try {
|
623
641
|
doctype = (_ref = exp.match(/^(\!{3}.*)/)) != null ? _ref[1] : void 0;
|
624
642
|
if (doctype) {
|
@@ -626,14 +644,14 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
|
|
626
644
|
doctype: doctype
|
627
645
|
};
|
628
646
|
}
|
629
|
-
tokens = exp.match(/^((?:[#%\.][a-z0-9_:\-]*[\/]?)+)(?:([\(\{].*[\)\}])?([\<\>]{0,2})(
|
647
|
+
tokens = exp.match(/^((?:[#%\.][a-z0-9_:\-]*[\/]?)+)(?:([\(\{].*[\)\}])?([\<\>]{0,2})(?=[=&!~])(.*)?|([\(\{].*[\)\}])?([\<\>]{0,2}))(.*)?/i);
|
630
648
|
haml = tokens[1];
|
631
|
-
attributes = tokens[2] || tokens[
|
632
|
-
whitespace = tokens[3] || tokens[
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
assignment =
|
649
|
+
attributes = tokens[2] || tokens[5];
|
650
|
+
whitespace = tokens[3] || tokens[6];
|
651
|
+
assignment = tokens[4] || tokens[7];
|
652
|
+
if (assignment && !assignment.match(/^(=|!=|&=|~)/)) {
|
653
|
+
text = assignment.replace(/^ /, '');
|
654
|
+
assignment = void 0;
|
637
655
|
}
|
638
656
|
if (whitespace) {
|
639
657
|
if (whitespace.indexOf('>') !== -1) this.wsRemoval.around = true;
|
@@ -805,11 +823,13 @@ require.define("/nodes/haml.js", function (require, module, exports, __dirname,
|
|
805
823
|
|
806
824
|
require.define("/nodes/code.js", function (require, module, exports, __dirname, __filename) {
|
807
825
|
(function() {
|
808
|
-
var Code, Node;
|
826
|
+
var Code, Node, p;
|
809
827
|
var __hasProp = Object.prototype.hasOwnProperty, __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; };
|
810
828
|
|
811
829
|
Node = require('./node');
|
812
830
|
|
831
|
+
p = require('../helper').preserve;
|
832
|
+
|
813
833
|
module.exports = Code = (function() {
|
814
834
|
|
815
835
|
__extends(Code, Node);
|
@@ -829,7 +849,7 @@ require.define("/nodes/code.js", function (require, module, exports, __dirname,
|
|
829
849
|
return this.closer = this.markRunningCode(" ''");
|
830
850
|
}
|
831
851
|
} else if (identifier === '~') {
|
832
|
-
return this.opener = this.markInsertingCode(
|
852
|
+
return this.opener = this.markInsertingCode(p(code));
|
833
853
|
} else if (identifier === '&=' || (identifier === '=' && this.escapeHtml)) {
|
834
854
|
return this.opener = this.markInsertingCode(code, true);
|
835
855
|
} else if (identifier === '!=' || (identifier === '=' && !this.escapeHtml)) {
|
@@ -837,12 +857,6 @@ require.define("/nodes/code.js", function (require, module, exports, __dirname,
|
|
837
857
|
}
|
838
858
|
};
|
839
859
|
|
840
|
-
Code.prototype.findAndPreserve = function(code) {
|
841
|
-
return code.replace(/<(pre|textarea)>(.*?)<\/\1>/g, function(text) {
|
842
|
-
return text.replace('\\n', '\&\#x000A;');
|
843
|
-
});
|
844
|
-
};
|
845
|
-
|
846
860
|
return Code;
|
847
861
|
|
848
862
|
})();
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_coffee_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Kessler
|