Dependency cleanup

This commit is contained in:
Patrick Steele-Idem 2014-05-06 10:45:13 -06:00
parent c87a2fd7ec
commit 9520a69c83
5 changed files with 135 additions and 98 deletions

View File

@ -16,12 +16,24 @@
'use strict';
var createError = require('raptor-util').createError;
var objects = require('raptor-objects');
var escapeXmlAttr = require('raptor-xml/util').escapeXmlAttr;
var escapeXmlAttr = require('raptor-util/escapeXml').attr;
var XML_URI = 'http://www.w3.org/XML/1998/namespace';
var XML_URI_ALT = 'http://www.w3.org/XML/1998/namespace';
var forEachEntry = require('raptor-util').forEachEntry;
function isEmpty(o) {
if (!o) {
return true;
}
for (var k in o) {
if (o.hasOwnProperty(k)) {
return false;
}
}
return true;
}
function ElementNode(localName, namespace, prefix) {
ElementNode.$super.call(this, 'element');
if (!this._elementNode) {
@ -132,7 +144,7 @@ ElementNode.prototype = {
var attrNS = this.attributesByNS[namespace] || (this.attributesByNS[namespace] = {});
if (attrNS) {
delete attrNS[localName];
if (objects.isEmpty(attrNS)) {
if (isEmpty(attrNS)) {
delete this.attributesByNS[namespace];
}
}
@ -153,7 +165,7 @@ ElementNode.prototype = {
return preserveSpace;
},
hasAttributesAnyNS: function () {
return !objects.isEmpty(this.attributesByNS);
return !isEmpty(this.attributesByNS);
},
hasAttributes: function () {
return this.hasAttributesNS('');

View File

@ -16,7 +16,6 @@
'use strict';
var createError = require('raptor-util').createError;
var operatorsRegExp = /"(?:[^"]|\\")*"|'(?:[^']|\\')*'|\s+(?:and|or|lt|gt|eq|ne|lt|gt|ge|le)\s+/g;
var strings = require('raptor-strings');
var replacements = {
'and': ' && ',
'or': ' || ',
@ -29,7 +28,7 @@ var replacements = {
};
function handleBinaryOperators(str) {
return str.replace(operatorsRegExp, function (match) {
return replacements[strings.trim(match)] || match;
return replacements[match.trim()] || match;
});
}
function Expression(expression, replaceSpecialOperators) {

View File

@ -1,60 +1,88 @@
var sax = require('raptor-xml/sax');
var createError = require('raptor-util').createError;
var sax = require("sax");
var extend = require('raptor-util/extend');
function ParseTreeBuilderXml(taglibs) {
ParseTreeBuilderXml.$super.apply(this, arguments);
this.parser = null;
this.filePath = null;
}
ParseTreeBuilderXml.prototype = {
getPos: function() {
return this.parser.getPos();
var parser = this.parser;
var filePath = this.filePath;
var line = parser.line + 1;
return {
line: line,
column: parser.column,
filePath: filePath,
toString: function() {
return this.filePath + ":" + this.line + ":" + this.column;
}
};
},
doParse: function (src, filePath) {
var parser = this.parser = sax.createParser({
trim: false,
normalize: false,
dom: src.documentElement != null
});
this.filePath = filePath;
var parser = this.parser = sax.parser(true /*strict*/, {
trim: false,
normalize: false,
lowercasetags: false,
xmlns: true
});
var _this = this;
extend(parser, {
onerror: function(e) {
throw e;
},
ontext: function(text) {
text = text.replace(/\r\n|\r/g, "\n");
_this.handleCharacters(text);
},
parser.on({
error: function (e) {
throw createError(e);
oncdata: function(text) {
text = text.replace(/\r\n|\r/g, "\n");
_this.handleCharacters(text);
},
characters: function (t) {
_this.handleCharacters(t);
},
cdata: function (t) {
_this.handleCharacters(t);
},
startElement: function (elNode) {
onopentag: function (node) {
var el = {
namespace: elNode.getNamespaceURI(),
prefix: elNode.getPrefix(),
localName: elNode.getLocalName()
namespace: node.uri,
prefix: node.prefix,
localName: node.local
};
var attributes = elNode.getAttributes().map(function (attr) {
var attributes = Object.keys(node.attributes).map(function(attrName) {
var attr = node.attributes[attrName];
return {
namespace: attr.getNamespaceURI(),
localName: attr.getLocalName(),
prefix: attr.getPrefix(),
value: attr.getValue()
namespace: attr.uri,
localName: attr.local,
prefix: attr.prefix,
value: attr.value
};
});
_this.handleStartElement(el, attributes);
},
endElement: function () {
_this.handleEndElement();
}
}, this);
parser.parse(src, filePath);
onclosetag: function () {
_this.handleEndElement();
},
oncomment: function (comment) {
}
});
parser.write(src).close();
}
};

View File

@ -15,7 +15,7 @@
*/
'use strict';
var createError = require('raptor-util').createError;
var escapeXml = require('raptor-xml/util').escapeXml;
var escapeXml = require('raptor-util/escapeXml');
var EscapeXmlContext = require('./EscapeXmlContext');
var attrReplace = /[&<>\"\']/g;

View File

@ -1,61 +1,59 @@
{
"name": "raptor-templates",
"description": "Raptor Templates",
"keywords": [
"templating",
"template",
"async",
"streaming"
],
"repository": {
"type": "git",
"url": "https://github.com/raptorjs3/raptor-templates.git"
},
"scripts": {
"test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/ dust/"
},
"author": "Patrick Steele-Idem <pnidem@gmail.com>",
"maintainers": [
"Patrick Steele-Idem <pnidem@gmail.com>"
],
"dependencies": {
"raptor-detect": "^0.2.0-beta",
"raptor-logging": "^0.2.0-beta",
"raptor-strings": "^0.2.0-beta",
"raptor-regexp": "^0.2.0-beta",
"raptor-util": "^0.2.0-beta",
"raptor-arrays": "^0.2.0-beta",
"raptor-json": "^0.2.0-beta",
"raptor-modules": "^0.2.0-beta",
"raptor-render-context": "^0.2.0-beta",
"raptor-data-providers": "^0.2.0-beta",
"raptor-xml": "^0.2.0-beta",
"raptor-objects": "^0.2.0-beta",
"raptor-ecma": "^0.2.0-beta",
"htmlparser2": "~3.5.1",
"char-props": "~0.1.5",
"raptor-promises": "^0.2.0-beta",
"raptor-args": "^0.1.9-beta",
"minimatch": "^0.2.14",
"property-handlers": "^0.2.1-beta",
"raptor-dust": "^0.3.6-beta"
},
"devDependencies": {
"mocha": "~1.15.1",
"chai": "~1.8.1",
"jshint": "^2.5.0",
"raptor-cache": "^0.2.7-beta",
"dustjs-linkedin": "^2.3.4",
"through": "^2.3.4"
},
"license": "Apache License v2.0",
"bin": {
"rhtmlc": "bin/rhtmlc"
},
"main": "runtime/raptor-templates-runtime.js",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"ebay": {},
"version": "1.0.0"
}
"name": "raptor-templates",
"description": "Raptor Templates",
"keywords": [
"templating",
"template",
"async",
"streaming"
],
"repository": {
"type": "git",
"url": "https://github.com/raptorjs3/raptor-templates.git"
},
"scripts": {
"test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/ dust/"
},
"author": "Patrick Steele-Idem <pnidem@gmail.com>",
"maintainers": [
"Patrick Steele-Idem <pnidem@gmail.com>"
],
"dependencies": {
"raptor-detect": "^0.2.0-beta",
"raptor-logging": "^0.2.0-beta",
"raptor-strings": "^0.2.0-beta",
"raptor-regexp": "^0.2.0-beta",
"raptor-util": "^0.2.0-beta",
"raptor-json": "^0.2.0-beta",
"raptor-modules": "^0.2.0-beta",
"raptor-render-context": "^0.2.0-beta",
"raptor-data-providers": "^0.2.0-beta",
"raptor-ecma": "^0.2.0-beta",
"htmlparser2": "~3.5.1",
"char-props": "~0.1.5",
"raptor-promises": "^0.2.0-beta",
"raptor-args": "^0.1.9-beta",
"minimatch": "^0.2.14",
"property-handlers": "^0.2.1-beta",
"raptor-dust": "^0.3.6-beta",
"sax": "^0.6.0"
},
"devDependencies": {
"mocha": "~1.15.1",
"chai": "~1.8.1",
"jshint": "^2.5.0",
"raptor-cache": "^0.2.7-beta",
"dustjs-linkedin": "^2.3.4",
"through": "^2.3.4"
},
"license": "Apache License v2.0",
"bin": {
"rhtmlc": "bin/rhtmlc"
},
"main": "runtime/raptor-templates-runtime.js",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"ebay": {},
"version": "0.2.38-beta"
}