Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Sep 22, 2009
1 parent da9083f commit fbf1c23
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/seethrough/seethrough.js
Expand Up @@ -39,11 +39,11 @@ function d(msg) {
return;

if(!arguments.callee.printFn) {
if(typeof(print) == 'function')
if(typeof(print) == "function")
// command-line spidermonkey
arguments.callee.printFn = print;
else if(typeof(app) == 'object' &&
typeof(app.log) == 'function')
else if(typeof(app) == "object" &&
typeof(app.log) == "function")
// helma
arguments.callee.printFn = function(s) { app.log(s) };
else
Expand All @@ -53,7 +53,7 @@ function d(msg) {
var output;
var stack = (new Error()).stack;
if(stack)
output = stack.split('\n')[2] + ':' + msg;
output = stack.split("\n")[2] + ":" + msg;
else
output = msg;

Expand All @@ -66,6 +66,7 @@ function Template(source, element) {
XML.ignoreComments = false;
XML.ignoreWhitespace = false;
XML.prettyPrinting = false;
if (source.isFile && source.isFile()) source = source.read();
source = /(^[\s\S]*?(?=\<[A-Za-z]))([\s\S]*>(?=[^\>]*$))/.exec(source.toString());
this.header = !element ? source[1] : "";
var xml = new XML(source[2]);
Expand Down Expand Up @@ -99,13 +100,13 @@ Template.prototype = {
compile: function(source) {
source = source || this.body;
if (source instanceof XMLList) {
d(' - Compiling children');
d(" - Compiling children");
var children = [];
for each(var child in source) {
children.push(this.compile(child));
}
return (function(children, data) {
d(' * Rendering children')
d(" * Rendering children")
var outChildren = new XMLList();
children.forEach(function(child) {
outChildren += child(data);
Expand All @@ -119,7 +120,7 @@ Template.prototype = {
delete xmlBase.*::*;
return (function renderElement(source, processors, children, data) {
var xmlOut = source.copy();
d('* Rendering ' + xmlOut.name());
d("* Rendering " + xmlOut.name());
if (processors.length > 0)
processors.forEach(function(processor) {
xmlOut = processor(xmlOut, data, children);
Expand All @@ -129,7 +130,7 @@ Template.prototype = {
if (typeof xmlChildren != "undefined")
for (var i=0,l=xmlChildren.length(); i<l; i++) {
var xmlChild = xmlChildren[i];
if (xmlChild.nodeKind() == 'attribute') xmlOut.@[xmlChild.name()] = xmlChild.toString();
if (xmlChild.nodeKind() == "attribute") xmlOut.@[xmlChild.name()] = xmlChild.toString();
else xmlOut.appendChild(xmlChild);
}
}
Expand All @@ -143,7 +144,7 @@ Template.prototype = {
}).bind(this, source);
break;
default:
throw new Error('Compile error: unhandled node kind. (' + xml.nodeKind() + ')');
throw new Error("Compile error: unhandled node kind. (" + xml.nodeKind() + ")");
}
}
},
Expand Down

0 comments on commit fbf1c23

Please sign in to comment.