Skip to content

Commit 7127ed3

Browse files
author
Joscha Rohmann
committed
Implemented Serverside comment query parsing.
1 parent c17f262 commit 7127ed3

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/node/parseToVirtual.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
define([
2-
'../query/VirtualElement'
3-
], function (VirtualElement) {
2+
'../query/VirtualElement',
3+
'../query/VirtualComment',
4+
'../query/Expression',
5+
'../var/trimRegExp',
6+
'../query/var/dataQueryAttr'
7+
], function (VirtualElement, VirtualComment, Expression, trimRegExp, dataQueryAttr) {
48
var parse5 = require('parse5');
59

610
var selfClosingTags = {
@@ -98,7 +102,20 @@ define([
98102
},
99103

100104
comment: function(text /*, [location] */) {
101-
//Handle comments here
105+
var trimmedComment = text.replace(trimRegExp, '');
106+
var comment;
107+
108+
if (trimmedComment.indexOf('blocks') === 0) {
109+
comment = new VirtualComment(text);
110+
comment._parent = parent;
111+
comment._attributes[dataQueryAttr] = trimmedComment.substring(6);
112+
parent._children.push(comment);
113+
parent = comment;
114+
} else if (trimmedComment.indexOf('/blocks') === 0) {
115+
parent = parent._parent;
116+
} else {
117+
parent._children.push('<!--' + text + '-->');
118+
}
102119
}
103120
}, {
104121
decodeHtmlEntities: false

0 commit comments

Comments
 (0)