diff --git a/compiler/lib/ParseTreeBuilderHtml.js b/compiler/lib/ParseTreeBuilderHtml.js
index 7747fc305..6ce41ad48 100644
--- a/compiler/lib/ParseTreeBuilderHtml.js
+++ b/compiler/lib/ParseTreeBuilderHtml.js
@@ -43,13 +43,16 @@ function ParseTreeBuilderHtml(taglibs) {
ParseTreeBuilderHtml.prototype = {
getPos: function() {
- return this.createPos(this.parser.startIndex);
+ return this.parser ? this.createPos(this.parser.startIndex) : null;
},
doParse: function (src, filePath) {
var _this = this;
+ // Create a pseudo root node
+ this.handleStartElement(splitName('c:template'), []);
+
var parser = this.parser = new htmlparser.Parser({
onopentag: function(name, attribs){
var el = splitName(name);
@@ -78,6 +81,9 @@ ParseTreeBuilderHtml.prototype = {
}, parserOptions);
parser.write(src);
parser.end();
+
+ // End the pseudo root node:
+ _this.handleEndElement();
}
};
diff --git a/compiler/lib/parser.js b/compiler/lib/parser.js
index 96e49b12a..48fca5a24 100644
--- a/compiler/lib/parser.js
+++ b/compiler/lib/parser.js
@@ -1,7 +1,14 @@
+require('raptor-ecma/es6');
var ParseTreeBuilderHtml = require('./ParseTreeBuilderHtml');
+var ParseTreeBuilderXml = require('./ParseTreeBuilderXml');
function parse(src, filePath, taglibs) {
- var parseTreeBuilder = new ParseTreeBuilderHtml(taglibs);
+ var ParseTreeBuilder = filePath.endsWith('.rxml') ?
+ ParseTreeBuilderXml :
+ ParseTreeBuilderHtml;
+
+ var parseTreeBuilder = new ParseTreeBuilder(taglibs);
+
return parseTreeBuilder.parse(src, filePath);
}
diff --git a/test-render.sh b/test-render.sh
index e70044c80..30fbe894c 100755
--- a/test-render.sh
+++ b/test-render.sh
@@ -1 +1 @@
-node_modules/.bin/mocha --ui bdd --reporter spec ./test/render-tests.js
\ No newline at end of file
+node_modules/.bin/mocha --ui bdd --reporter spec ./test/render-rhtml-tests.js
\ No newline at end of file
diff --git a/test/render-tests.js b/test/render-rhtml-tests.js
similarity index 69%
rename from test/render-tests.js
rename to test/render-rhtml-tests.js
index 50a4c2137..80c784f19 100644
--- a/test/render-tests.js
+++ b/test/render-rhtml-tests.js
@@ -56,7 +56,7 @@ function testRender(path, data, done, options) {
}
-describe('raptor-templates' , function() {
+describe('raptor-templates/rhtml' , function() {
beforeEach(function(done) {
// for (var k in require.cache) {
@@ -81,7 +81,7 @@ describe('raptor-templates' , function() {
});
it("should allow for text replacement", function(done) {
- testRender("test-project/html-templates/text-replacement.rhtml", {
+ testRender("test-project/rhtml-templates/text-replacement.rhtml", {
person: {
name: "John",
address: {
@@ -94,8 +94,8 @@ describe('raptor-templates' , function() {
}, done);
});
- it.only("should render simple template with logic", function(done) {
- testRender("test-project/html-templates/simple.rhtml", {
+ it("should render simple template with logic", function(done) {
+ testRender("test-project/rhtml-templates/simple.rhtml", {
message: "Hello World!",
rootClass: "title",
colors: ["red", "green", "blue"]
@@ -103,63 +103,63 @@ describe('raptor-templates' , function() {
});
it("should allow for simple template handlers", function(done) {
- testRender("test-project/html-templates/simple-handlers.rhtml", {dynamic: "universe"}, done);
+ testRender("test-project/rhtml-templates/simple-handlers.rhtml", {dynamic: "universe"}, done);
});
it("should allow for template handlers with nested body content", function(done) {
- testRender("test-project/html-templates/nested-handlers.rhtml", {showConditionalTab: false}, done);
+ testRender("test-project/rhtml-templates/nested-handlers.rhtml", {showConditionalTab: false}, done);
});
it("should allow entity expressions", function(done) {
- testRender("test-project/html-templates/entities.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/entities.rhtml", {}, done);
});
it("should allow escaped expressions", function(done) {
- testRender("test-project/html-templates/escaped.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/escaped.rhtml", {}, done);
});
it("should allow complex expressions", function(done) {
- testRender("test-project/html-templates/expressions.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/expressions.rhtml", {}, done);
});
it("should allow whitespace to be removed", function(done) {
- testRender("test-project/html-templates/whitespace.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/whitespace.rhtml", {}, done);
});
it("should handle whitespace when using expressions", function(done) {
- testRender("test-project/html-templates/whitespace2.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/whitespace2.rhtml", {}, done);
});
it("should handle whitespace when using expressions", function(done) {
- testRender("test-project/html-templates/whitespace2.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/whitespace2.rhtml", {}, done);
});
it("should normalize whitespace", function(done) {
- testRender("test-project/html-templates/whitespace3.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/whitespace3.rhtml", {}, done);
});
it("should handle whitespace correctly for mixed text and element children", function(done) {
- testRender("test-project/html-templates/whitespace-inline-elements.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/whitespace-inline-elements.rhtml", {}, done);
});
it("should allow HTML output that is not well-formed XML", function(done) {
- testRender("test-project/html-templates/html.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/html.rhtml", {}, done);
});
it("should allow for looping", function(done) {
- testRender("test-project/html-templates/looping.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/looping.rhtml", {}, done);
});
it("should allow for looping over properties", function(done) {
- testRender("test-project/html-templates/looping-props.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/looping-props.rhtml", {}, done);
});
it("should allow for dynamic attributes", function(done) {
- testRender("test-project/html-templates/attrs.rhtml", {"myAttrs": {style: "background-color: #FF0000; ", "class": "my-div"}}, done);
+ testRender("test-project/rhtml-templates/attrs.rhtml", {"myAttrs": {style: "background-color: #FF0000; ", "class": "my-div"}}, done);
});
it("should allow for choose...when statements", function(done) {
- testRender("test-project/html-templates/choose-when.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/choose-when.rhtml", {}, done);
});
it("should not allow to be before a tag", function(done) {
@@ -171,7 +171,7 @@ describe('raptor-templates' , function() {
}
try {
- testRender("test-project/html-templates/choose-when-invalid-otherwise-not-last.rhtml", {}, fakeDone);
+ testRender("test-project/rhtml-templates/choose-when-invalid-otherwise-not-last.rhtml", {}, fakeDone);
}
catch(_e) {
e = _e;
@@ -182,43 +182,43 @@ describe('raptor-templates' , function() {
});
it("should allow for functions", function(done) {
- testRender("test-project/html-templates/def.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/def.rhtml", {}, done);
});
it("should allow for functions", function(done) {
- testRender("test-project/html-templates/with.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/with.rhtml", {}, done);
});
it("should allow for scriptlets", function(done) {
- testRender("test-project/html-templates/scriptlet.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/scriptlet.rhtml", {}, done);
});
it("should allow for when and otherwise as attributes", function(done) {
- testRender("test-project/html-templates/choose-when-attributes.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/choose-when-attributes.rhtml", {}, done);
});
it("should allow for elements to be stripped out at compile time", function(done) {
- testRender("test-project/html-templates/strip.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/strip.rhtml", {}, done);
});
it("should allow for body content to be replaced with the result of an expression", function(done) {
- testRender("test-project/html-templates/content.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/content.rhtml", {}, done);
});
it("should allow for an element to be replaced with the result of an expression", function(done) {
- testRender("test-project/html-templates/replace.rhtml", {message: "Hello World!"}, done);
+ testRender("test-project/rhtml-templates/replace.rhtml", {message: "Hello World!"}, done);
});
it("should allow for includes", function(done) {
- testRender("test-project/html-templates/include.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/include.rhtml", {}, done);
});
it("should allow for ", function(done) {
- testRender("test-project/html-templates/invoke.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/invoke.rhtml", {}, done);
});
it("should allow for require", function(done) {
- testRender("test-project/html-templates/require.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/require.rhtml", {}, done);
});
@@ -244,7 +244,7 @@ describe('raptor-templates' , function() {
// }
// };
- // tryTemplate("test-project/html-templates/errors.rhtml", function(message, errors) {
+ // tryTemplate("test-project/rhtml-templates/errors.rhtml", function(message, errors) {
// var len = errors ? errors.length : -1;
// expect(len).toEqual(25);
@@ -255,15 +255,15 @@ describe('raptor-templates' , function() {
// });
it("should allow static file includes", function(done) {
- testRender("test-project/html-templates/include-resource-static.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/include-resource-static.rhtml", {}, done);
});
it("should allow HTML pages with inline script", function(done) {
- testRender("test-project/html-templates/inline-script.rhtml", {name: "World"}, done);
+ testRender("test-project/rhtml-templates/inline-script.rhtml", {name: "World"}, done);
});
it("should allow CDATA inside templates", function(done) {
- testRender("test-project/html-templates/cdata.rhtml", {name: "World"}, done);
+ testRender("test-project/rhtml-templates/cdata.rhtml", {name: "World"}, done);
});
// it("should allow type conversion", function(done) {
@@ -272,31 +272,31 @@ describe('raptor-templates' , function() {
// });
it("should allow for if...else", function(done) {
- testRender("test-project/html-templates/if-else.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/if-else.rhtml", {}, done);
});
it("should allow for expressions and variables inside JavaScript strings", function(done) {
- testRender("test-project/html-templates/string-expressions.rhtml", {name: "John", count: 10}, done);
+ testRender("test-project/rhtml-templates/string-expressions.rhtml", {name: "John", count: 10}, done);
});
it("should allow for simple conditionals", function(done) {
- testRender("test-project/html-templates/simple-conditionals.rhtml", {name: "John", count: 51}, done);
+ testRender("test-project/rhtml-templates/simple-conditionals.rhtml", {name: "John", count: 51}, done);
});
it("should allow for conditional attributes", function(done) {
- testRender("test-project/html-templates/conditional-attributes.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/conditional-attributes.rhtml", {}, done);
});
it("should allow for dynamic attributes to be passed to tag renderer using a custom property name", function(done) {
- testRender("test-project/html-templates/dynamic-attributes.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/dynamic-attributes.rhtml", {}, done);
});
it("should allow for dynamic attributes to be passed to tag renderer", function(done) {
- testRender("test-project/html-templates/dynamic-attributes2.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/dynamic-attributes2.rhtml", {}, done);
});
it("should allow for dynamic attributes to be passed to tag renderer as part of input object", function(done) {
- testRender("test-project/html-templates/dynamic-attributes3.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/dynamic-attributes3.rhtml", {}, done);
});
// it("should allow for nodes to be converted to expressions", function(done) {
@@ -325,48 +325,48 @@ describe('raptor-templates' , function() {
// });
it("should allow for nested attributes", function(done) {
- testRender("test-project/html-templates/nested-attrs.rhtml", {active: true}, done);
+ testRender("test-project/rhtml-templates/nested-attrs.rhtml", {active: true}, done);
});
it("should allow for new variables to be created and assigned values", function(done) {
- testRender("test-project/html-templates/var.rhtml", {active: true}, done);
+ testRender("test-project/rhtml-templates/var.rhtml", {active: true}, done);
});
it("should handle XML escaping correctly", function(done) {
- testRender("test-project/html-templates/xml-escaping.rhtml", {name: "", welcome: 'Welcome'}, done);
+ testRender("test-project/rhtml-templates/xml-escaping.rhtml", {name: "", welcome: 'Welcome'}, done);
});
it("should allow for a doctype tag and a doctype attribute", function(done) {
- testRender("test-project/html-templates/doctype.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/doctype.rhtml", {}, done);
});
it("should allow for using templates to render custom tags", function(done) {
- testRender("test-project/html-templates/template-as-tag.rhtml", {title: "My Page Title"}, done);
+ testRender("test-project/rhtml-templates/template-as-tag.rhtml", {title: "My Page Title"}, done);
});
it("should allow for caching HTML fragments", function(done) {
- testRender("test-project/html-templates/caching.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/caching.rhtml", {}, done);
});
it("should escape XML in text node when enabled", function(done) {
- testRender("test-project/html-templates/escape-xml-enabled.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/escape-xml-enabled.rhtml", {}, done);
});
it("should not escape XML in text node when disabled", function(done) {
- testRender("test-project/html-templates/escape-xml-disabled.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/escape-xml-disabled.rhtml", {}, done);
});
it("should allow for attributes with default values", function(done) {
- testRender("test-project/html-templates/default-attributes.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/default-attributes.rhtml", {}, done);
});
it("should allow for input expressions to be provided to tag handler nodes", function(done) {
- testRender("test-project/html-templates/tag-input-expressions.rhtml", {name: "Frank", adult: true}, done);
+ testRender("test-project/rhtml-templates/tag-input-expressions.rhtml", {name: "Frank", adult: true}, done);
});
it("should allow for using layouts", function(done) {
- testRender("test-project/html-templates/layout-use.rhtml", {}, done);
+ testRender("test-project/rhtml-templates/layout-use.rhtml", {}, done);
});
});
diff --git a/test/render-rxml-tests.js b/test/render-rxml-tests.js
new file mode 100644
index 000000000..e52a2aca1
--- /dev/null
+++ b/test/render-rxml-tests.js
@@ -0,0 +1,366 @@
+'use strict';
+var chai = require('chai');
+chai.Assertion.includeStack = true;
+require('chai').should();
+var expect = require('chai').expect;
+var nodePath = require('path');
+var fs = require('fs');
+
+var StringBuilder = require('raptor-strings/StringBuilder');
+
+function testRender(path, data, done, options) {
+ var inputPath = nodePath.join(__dirname, path);
+ var expectedPath = nodePath.join(__dirname, path + '.expected.html');
+ var actualPath = nodePath.join(__dirname, path + '.actual.html');
+ options = options || {};
+ var compiledPath = nodePath.join(__dirname, path + '.actual.js');
+
+ var compiler = require('../compiler').createCompiler(inputPath);
+ var src = fs.readFileSync(inputPath, {encoding: 'utf8'});
+
+ var compiledSrc = compiler.compile(src);
+ fs.writeFileSync(compiledPath, compiledSrc, {encoding: 'utf8'});
+
+
+ // console.log('\nCompiled (' + inputPath + '):\n---------\n' + compiledSrc);
+
+
+
+ var raptorTemplates = require('../');
+ var Context = raptorTemplates.Context;
+ var context = options.context || new Context(new StringBuilder());
+
+ raptorTemplates.render(inputPath, data, context)
+ .on('end', function() {
+ var output = context.getOutput();
+
+ fs.writeFileSync(actualPath, output, {encoding: 'utf8'});
+
+ var expected;
+ try {
+ expected = options.expected || fs.readFileSync(expectedPath, {encoding: 'utf8'});
+ }
+ catch(e) {
+ expected = 'TBD';
+ fs.writeFileSync(expectedPath, expected, {encoding: 'utf8'});
+ }
+
+ if (output !== expected) {
+ throw new Error('Unexpected output for "' + inputPath + '":\nEXPECTED (' + expectedPath + '):\n---------\n' + expected +
+ '\n---------\nACTUAL (' + actualPath + '):\n---------\n' + output + '\n---------');
+ }
+
+ done();
+ })
+ .on('error', done);
+
+}
+
+describe('raptor-templates/rxml' , function() {
+
+ beforeEach(function(done) {
+ // for (var k in require.cache) {
+ // if (require.cache.hasOwnProperty(k)) {
+ // delete require.cache[k];
+ // }
+ // }
+
+ // require('raptor-logging').configureLoggers({
+ // 'raptor-templates': 'INFO'
+ // });
+
+ done();
+ });
+
+
+ it("should allow for text replacement", function(done) {
+ testRender("test-project/rxml-templates/text-replacement.rxml", {
+ person: {
+ name: "John",
+ address: {
+ city: "San Jose",
+ state: "CA",
+ line1: "2065 E. Hamilton Ave.",
+ zip: "95125"
+ }
+ }
+ }, done);
+ });
+
+ it("should render simple template with logic", function(done) {
+ testRender("test-project/rxml-templates/simple.rxml", {
+ message: "Hello World!",
+ rootClass: "title",
+ colors: ["red", "green", "blue"]
+ }, done);
+ });
+
+ it("should allow for simple template handlers", function(done) {
+ testRender("test-project/rxml-templates/simple-handlers.rxml", {dynamic: "universe"}, done);
+ });
+
+ it("should allow for template handlers with nested body content", function(done) {
+ testRender("test-project/rxml-templates/nested-handlers.rxml", {showConditionalTab: false}, done);
+ });
+
+ it("should allow entity expressions", function(done) {
+ testRender("test-project/rxml-templates/entities.rxml", {}, done);
+ });
+
+ it("should allow escaped expressions", function(done) {
+ testRender("test-project/rxml-templates/escaped.rxml", {}, done);
+ });
+
+ it("should allow complex expressions", function(done) {
+ testRender("test-project/rxml-templates/expressions.rxml", {}, done);
+ });
+
+ it("should allow whitespace to be removed", function(done) {
+ testRender("test-project/rxml-templates/whitespace.rxml", {}, done);
+ });
+
+ it("should handle whitespace when using expressions", function(done) {
+ testRender("test-project/rxml-templates/whitespace2.rxml", {}, done);
+ });
+
+ it("should handle whitespace when using expressions", function(done) {
+ testRender("test-project/rxml-templates/whitespace2.rxml", {}, done);
+ });
+
+ it("should normalize whitespace", function(done) {
+ testRender("test-project/rxml-templates/whitespace3.rxml", {}, done);
+ });
+
+ it("should handle whitespace correctly for mixed text and element children", function(done) {
+ testRender("test-project/rxml-templates/whitespace-inline-elements.rxml", {}, done);
+ });
+
+ it("should allow HTML output that is not well-formed XML", function(done) {
+ testRender("test-project/rxml-templates/html.rxml", {}, done);
+ });
+
+ it("should allow for looping", function(done) {
+ testRender("test-project/rxml-templates/looping.rxml", {}, done);
+ });
+
+ it("should allow for looping over properties", function(done) {
+ testRender("test-project/rxml-templates/looping-props.rxml", {}, done);
+ });
+
+ it("should allow for dynamic attributes", function(done) {
+ testRender("test-project/rxml-templates/attrs.rxml", {"myAttrs": {style: "background-color: #FF0000; ", "class": "my-div"}}, done);
+ });
+
+ it("should allow for choose...when statements", function(done) {
+ testRender("test-project/rxml-templates/choose-when.rxml", {}, done);
+ });
+
+ it("should not allow to be before a tag", function(done) {
+
+ var e;
+
+ function fakeDone() {
+ done('Error expected');
+ }
+
+ try {
+ testRender("test-project/rxml-templates/choose-when-invalid-otherwise-not-last.rxml", {}, fakeDone);
+ }
+ catch(_e) {
+ e = _e;
+ }
+
+ expect(e != null).to.equal(true);
+ done();
+ });
+
+ it("should allow for functions", function(done) {
+ testRender("test-project/rxml-templates/def.rxml", {}, done);
+ });
+
+ it("should allow for functions", function(done) {
+ testRender("test-project/rxml-templates/with.rxml", {}, done);
+ });
+
+ it("should allow for scriptlets", function(done) {
+ testRender("test-project/rxml-templates/scriptlet.rxml", {}, done);
+ });
+
+ it("should allow for when and otherwise as attributes", function(done) {
+ testRender("test-project/rxml-templates/choose-when-attributes.rxml", {}, done);
+ });
+
+ it("should allow for elements to be stripped out at compile time", function(done) {
+ testRender("test-project/rxml-templates/strip.rxml", {}, done);
+ });
+
+ it("should allow for body content to be replaced with the result of an expression", function(done) {
+ testRender("test-project/rxml-templates/content.rxml", {}, done);
+ });
+
+ it("should allow for an element to be replaced with the result of an expression", function(done) {
+ testRender("test-project/rxml-templates/replace.rxml", {message: "Hello World!"}, done);
+ });
+
+ it("should allow for includes", function(done) {
+ testRender("test-project/rxml-templates/include.rxml", {}, done);
+ });
+
+ it("should allow for ", function(done) {
+ testRender("test-project/rxml-templates/invoke.rxml", {}, done);
+ });
+
+ it("should allow for require", function(done) {
+ testRender("test-project/rxml-templates/require.rxml", {}, done);
+ });
+
+
+ // it("should handle errors correctly", function(done) {
+
+
+
+ // var tryTemplate = function(path, callback) {
+ // try
+ // {
+ // compileAndRender(path, {}, null, true /* invalid */);
+ // callback("", []);
+ // }
+ // catch(e) {
+
+ // if (!e.errors) {
+ // logger.error('Error message for template at path "' + path + '": ' + e, e);
+ // }
+ // else {
+ // console.log('Error message for template at path "' + path + '": ' + e)
+ // }
+ // callback(e.toString(), e.errors);
+ // }
+ // };
+
+ // tryTemplate("test-project/rxml-templates/errors.rxml", function(message, errors) {
+ // var len = errors ? errors.length : -1;
+ // expect(len).toEqual(25);
+
+
+ // });
+
+
+ // });
+
+ it("should allow static file includes", function(done) {
+ testRender("test-project/rxml-templates/include-resource-static.rxml", {}, done);
+ });
+
+ it("should allow HTML pages with inline script", function(done) {
+ testRender("test-project/rxml-templates/inline-script.rxml", {name: "World"}, done);
+ });
+
+ it("should allow CDATA inside templates", function(done) {
+ testRender("test-project/rxml-templates/cdata.rxml", {name: "World"}, done);
+ });
+
+ // it("should allow type conversion", function(done) {
+ // var TypeConverter = require('raptor/templating/compiler/TypeConverter');
+ // expect(TypeConverter.convert('${entity:special}', "string", true).toString()).toEqual('"&special;"');
+ // });
+
+ it("should allow for if...else", function(done) {
+ testRender("test-project/rxml-templates/if-else.rxml", {}, done);
+ });
+
+ it("should allow for expressions and variables inside JavaScript strings", function(done) {
+ testRender("test-project/rxml-templates/string-expressions.rxml", {name: "John", count: 10}, done);
+ });
+
+ it("should allow for simple conditionals", function(done) {
+ testRender("test-project/rxml-templates/simple-conditionals.rxml", {name: "John", count: 51}, done);
+ });
+
+ it("should allow for conditional attributes", function(done) {
+ testRender("test-project/rxml-templates/conditional-attributes.rxml", {}, done);
+ });
+
+ it("should allow for dynamic attributes to be passed to tag renderer using a custom property name", function(done) {
+ testRender("test-project/rxml-templates/dynamic-attributes.rxml", {}, done);
+ });
+
+ it("should allow for dynamic attributes to be passed to tag renderer", function(done) {
+ testRender("test-project/rxml-templates/dynamic-attributes2.rxml", {}, done);
+ });
+
+ it("should allow for dynamic attributes to be passed to tag renderer as part of input object", function(done) {
+ testRender("test-project/rxml-templates/dynamic-attributes3.rxml", {}, done);
+ });
+
+ // it("should allow for nodes to be converted to expressions", function(done) {
+ // var ElementNode = require('raptor/templating/compiler/ElementNode');
+ // var TextNode = require('raptor/templating/compiler/TextNode');
+ // var TemplateBuilder = require('raptor/templating/compiler/TemplateBuilder');
+
+ // var compiler = require('raptor/templating/compiler').createCompiler();
+ // var template = new TemplateBuilder(compiler);
+
+ // var div = new ElementNode("div");
+ // var text = new TextNode("Hello World!");
+ // div.appendChild(text);
+
+ // var expression = div.getExpression(template).toString();
+ // var bodyContentExpression = div.getBodyContentExpression(template).toString();
+
+ // var sb = require('raptor/strings').createStringBuilder();
+ // var context = require('raptor/templating').createContext(sb);
+ // var output = eval(expression);
+ // expect(output.toString()).toEqual('Hello World!
');
+
+ // output = eval(bodyContentExpression);
+ // expect(output.toString()).toEqual('Hello World!');
+
+ // });
+
+ it("should allow for nested attributes", function(done) {
+ testRender("test-project/rxml-templates/nested-attrs.rxml", {active: true}, done);
+ });
+
+ it("should allow for new variables to be created and assigned values", function(done) {
+ testRender("test-project/rxml-templates/var.rxml", {active: true}, done);
+ });
+
+
+ it("should handle XML escaping correctly", function(done) {
+ testRender("test-project/rxml-templates/xml-escaping.rxml", {name: "", welcome: 'Welcome'}, done);
+ });
+
+ it("should allow for a doctype tag and a doctype attribute", function(done) {
+ testRender("test-project/rxml-templates/doctype.rxml", {}, done);
+ });
+
+ it("should allow for using templates to render custom tags", function(done) {
+ testRender("test-project/rxml-templates/template-as-tag.rxml", {title: "My Page Title"}, done);
+ });
+
+ it("should allow for caching HTML fragments", function(done) {
+ testRender("test-project/rxml-templates/caching.rxml", {}, done);
+ });
+
+ it("should escape XML in text node when enabled", function(done) {
+ testRender("test-project/rxml-templates/escape-xml-enabled.rxml", {}, done);
+ });
+
+ it("should not escape XML in text node when disabled", function(done) {
+ testRender("test-project/rxml-templates/escape-xml-disabled.rxml", {}, done);
+ });
+
+ it("should allow for attributes with default values", function(done) {
+ testRender("test-project/rxml-templates/default-attributes.rxml", {}, done);
+ });
+
+ it("should allow for input expressions to be provided to tag handler nodes", function(done) {
+ testRender("test-project/rxml-templates/tag-input-expressions.rxml", {name: "Frank", adult: true}, done);
+ });
+
+ it("should allow for using layouts", function(done) {
+ testRender("test-project/rxml-templates/layout-use.rxml", {}, done);
+ });
+
+});
+
diff --git a/test/test-project/custom-tag.rhtml b/test/test-project/custom-tag.rhtml
index b081ef018..2322fbf06 100644
--- a/test/test-project/custom-tag.rhtml
+++ b/test/test-project/custom-tag.rhtml
@@ -1,3 +1 @@
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rhtml-templates/conditional-attributes.rhtml b/test/test-project/rhtml-templates/conditional-attributes.rhtml
index 0179589cd..1a42333f2 100644
--- a/test/test-project/rhtml-templates/conditional-attributes.rhtml
+++ b/test/test-project/rhtml-templates/conditional-attributes.rhtml
@@ -1,7 +1,7 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rhtml-templates/dynamic-attributes.rhtml b/test/test-project/rhtml-templates/dynamic-attributes.rhtml
index 716a82ab5..ca9554963 100644
--- a/test/test-project/rhtml-templates/dynamic-attributes.rhtml
+++ b/test/test-project/rhtml-templates/dynamic-attributes.rhtml
@@ -1,6 +1,6 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rhtml-templates/dynamic-attributes2.rhtml b/test/test-project/rhtml-templates/dynamic-attributes2.rhtml
index c059be3fb..11fa7e73a 100644
--- a/test/test-project/rhtml-templates/dynamic-attributes2.rhtml
+++ b/test/test-project/rhtml-templates/dynamic-attributes2.rhtml
@@ -1,6 +1,6 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rhtml-templates/dynamic-attributes3.rhtml b/test/test-project/rhtml-templates/dynamic-attributes3.rhtml
index 00ed6e6a9..da3486790 100644
--- a/test/test-project/rhtml-templates/dynamic-attributes3.rhtml
+++ b/test/test-project/rhtml-templates/dynamic-attributes3.rhtml
@@ -1,6 +1,6 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rhtml-templates/simple-conditionals.rhtml b/test/test-project/rhtml-templates/simple-conditionals.rhtml
index 6a191a6d3..5e5e068b5 100644
--- a/test/test-project/rhtml-templates/simple-conditionals.rhtml
+++ b/test/test-project/rhtml-templates/simple-conditionals.rhtml
@@ -1,4 +1,4 @@
-
@@ -12,4 +12,4 @@
{?count>50;{?name;Hello $name! }Over 50;{?name;Hello $name! }50 or less}
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rhtml-templates/simple.rhtml b/test/test-project/rhtml-templates/simple.rhtml
index 93b61d764..ed08562a1 100644
--- a/test/test-project/rhtml-templates/simple.rhtml
+++ b/test/test-project/rhtml-templates/simple.rhtml
@@ -1,9 +1,6 @@
-
-
-
-
${message}
@@ -15,4 +12,4 @@
No colors!
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rhtml-templates/string-expressions.rhtml b/test/test-project/rhtml-templates/string-expressions.rhtml
index 43c12b2e6..bad5031f2 100644
--- a/test/test-project/rhtml-templates/string-expressions.rhtml
+++ b/test/test-project/rhtml-templates/string-expressions.rhtml
@@ -1,7 +1,7 @@
-
${name != null ? "Hello ${name.toUpperCase()}! You have $count new messages." : null}
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rhtml-templates/tag-input-expressions.rhtml b/test/test-project/rhtml-templates/tag-input-expressions.rhtml
index db55e64b3..240af3955 100644
--- a/test/test-project/rhtml-templates/tag-input-expressions.rhtml
+++ b/test/test-project/rhtml-templates/tag-input-expressions.rhtml
@@ -1,8 +1,8 @@
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rhtml-templates/text-replacement.rhtml b/test/test-project/rhtml-templates/text-replacement.rhtml
index 17b901573..c3aeb898c 100644
--- a/test/test-project/rhtml-templates/text-replacement.rhtml
+++ b/test/test-project/rhtml-templates/text-replacement.rhtml
@@ -1,8 +1,8 @@
-
Hello $person.name. You are from ${person.address.city}, $person.address.state
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/test/test-project/rxml-templates/include.rxml b/test/test-project/rxml-templates/include.rxml
index aee552d0f..be824bfcf 100644
--- a/test/test-project/rxml-templates/include.rxml
+++ b/test/test-project/rxml-templates/include.rxml
@@ -2,10 +2,10 @@
xmlns:c="http://raptorjs.org/templates/core"
params="">
-
-
-
-
+
+
+
+
Have a
wonderful
diff --git a/test/test-project/rxml-templates/layout-use.rxml b/test/test-project/rxml-templates/layout-use.rxml
index e2a9f8e55..78a3bde8e 100644
--- a/test/test-project/rxml-templates/layout-use.rxml
+++ b/test/test-project/rxml-templates/layout-use.rxml
@@ -1,19 +1,19 @@
-
+
BODY CONTENT
FOOTER CONTENT
-
+
HEADER CONTENT
BODY CONTENT
FOOTER CONTENT
-
+
BODY CONTENT
FOOTER CONTENT
-
+
BODY CONTENT
FOOTER CONTENT
diff --git a/test/test-project/rxml-templates/simple.rxml b/test/test-project/rxml-templates/simple.rxml
index 93b61d764..5d6796e79 100644
--- a/test/test-project/rxml-templates/simple.rxml
+++ b/test/test-project/rxml-templates/simple.rxml
@@ -1,8 +1,8 @@
-
-
+
${message}
diff --git a/test/test-project/rxml-templates/simple.rxml.expected.html b/test/test-project/rxml-templates/simple.rxml.expected.html
index 4ab7138f7..2faa09220 100644
--- a/test/test-project/rxml-templates/simple.rxml.expected.html
+++ b/test/test-project/rxml-templates/simple.rxml.expected.html
@@ -1 +1 @@
-Hello World!
\ No newline at end of file
+Hello World!Hello World!
\ No newline at end of file
diff --git a/test/test-project/simple.rhtml b/test/test-project/simple.rhtml
index 297ba1a9f..49fe4fe8a 100644
--- a/test/test-project/simple.rhtml
+++ b/test/test-project/simple.rhtml
@@ -1,3 +1 @@
-
- Hello John
-
\ No newline at end of file
+Hello John
\ No newline at end of file