Skip to content

Commit

Permalink
Merge pull request #141 from Kanaye/serverside-comment-expressions
Browse files Browse the repository at this point in the history
Implemented Serverside comment query parsing.
  • Loading branch information
astoilkov committed Apr 26, 2016
2 parents a6acd83 + 7127ed3 commit bb5b85c
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/node/parseToVirtual.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
define([
'../query/VirtualElement'
], function (VirtualElement) {
'../query/VirtualElement',
'../query/VirtualComment',
'../query/Expression',
'../var/trimRegExp',
'../query/var/dataQueryAttr'
], function (VirtualElement, VirtualComment, Expression, trimRegExp, dataQueryAttr) {
var parse5 = require('parse5');

var selfClosingTags = {
Expand Down Expand Up @@ -98,7 +102,20 @@ define([
},

comment: function(text /*, [location] */) {
//Handle comments here
var trimmedComment = text.replace(trimRegExp, '');
var comment;

if (trimmedComment.indexOf('blocks') === 0) {
comment = new VirtualComment(text);
comment._parent = parent;
comment._attributes[dataQueryAttr] = trimmedComment.substring(6);
parent._children.push(comment);
parent = comment;
} else if (trimmedComment.indexOf('/blocks') === 0) {
parent = parent._parent;
} else {
parent._children.push('<!--' + text + '-->');
}
}
}, {
decodeHtmlEntities: false
Expand Down

0 comments on commit bb5b85c

Please sign in to comment.