aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/webcals/template.js5
-rw-r--r--test/webcals/template_test.js15
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/webcals/template.js b/lib/webcals/template.js
index e966225..67205d4 100644
--- a/lib/webcals/template.js
+++ b/lib/webcals/template.js
@@ -80,6 +80,11 @@
content = false;
}
+ if (attrs && typeof(attrs.render) === 'function') {
+ content = attrs.render(this);
+ attrs = {};
+ }
+
if (typeof(tagDesc) === 'string') {
tagDesc = [this.defaultNamespace, tagDesc];
}
diff --git a/test/webcals/template_test.js b/test/webcals/template_test.js
index 05b61b6..eb1e280 100644
--- a/test/webcals/template_test.js
+++ b/test/webcals/template_test.js
@@ -81,6 +81,21 @@ suite('templates', function() {
);
});
+ test('when given a an object /w .render in content', function() {
+ var obj = {
+ render: function(template) {
+ return template.tag('baz');
+ }
+ };
+
+ var out = subject.tag('foo', obj);
+
+ assert.equal(
+ out,
+ '<N0:foo><N0:baz /></N0:foo>'
+ );
+ });
+
test('with attrs', function() {
var out = subject.tag('bar', {
value: 'val'