render content() by default

This commit is contained in:
David Greenspan
2013-07-09 17:11:05 -07:00
parent 3b4cfd9482
commit 7230c2f543
3 changed files with 11 additions and 4 deletions

View File

@@ -49,6 +49,7 @@ Template.item({
//});
Span = UIComponent.extend({
typeName: 'Span',
render: function (buf) {
buf("<span ",
{ attrs: function () {
@@ -69,6 +70,7 @@ Span = UIComponent.extend({
});
Div = UIComponent.extend({
typeName: 'Div',
render: function (buf) {
buf("<div style='background:cyan;margin:5px'>World",
"<input type=checkbox ",

View File

@@ -1,6 +1,7 @@
var Component = UIComponent;
_UI.Text = Component.extend({
typeName: 'Text',
_encodeEntities: _UI.encodeSpecialEntities,
_stringify: function (x) {
return String(x == null ? '' : x);
@@ -12,6 +13,7 @@ _UI.Text = Component.extend({
});
_UI.HTML = Component.extend({
typeName: 'HTML',
_stringify: function (x) {
return String(x == null ? '' : x);
},
@@ -22,8 +24,7 @@ _UI.HTML = Component.extend({
});
_UI.If = Component.extend({
content: function () { return null; },
elseContent: function () { return null; },
typeName: 'If',
render: function (buf) {
var self = this;
var condition = Deps.isolate(function () {

View File

@@ -113,7 +113,12 @@ Component({
// It's a DIV rather than a fragment so that jQuery can run against it.
_offscreen: null,
render: function (buf) {},
content: function () { return null; },
elseContent: function () { return null; },
render: function (buf) {
buf(this.content());
},
_populate: function (div) {
var self = this;
@@ -690,7 +695,6 @@ Component({
// Next up:
//
// - content()
// - Spacebars compiler
// - event maps
// - preview HTML