-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #416 - Allow split widget/render for template as entry
- Loading branch information
1 parent
3dc16a0
commit e37135f
Showing
11 changed files
with
143 additions
and
11 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
test/autotests/widgets-browser/sanity-check-template-entry-split/index.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div w-bind> | ||
Hello <span w-id="name">${data.name}</span>! | ||
</div> |
7 changes: 7 additions & 0 deletions
7
test/autotests/widgets-browser/sanity-check-template-entry-split/renderer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
getTemplateData: function(state, input) { | ||
return { | ||
name: input.name.toUpperCase() | ||
}; | ||
} | ||
}; |
12 changes: 12 additions & 0 deletions
12
test/autotests/widgets-browser/sanity-check-template-entry-split/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var expect = require('chai').expect; | ||
|
||
module.exports = function(helpers) { | ||
|
||
var widget = helpers.mount(require('./index.marko'), { name: 'Frank' }); | ||
|
||
expect(widget.el.innerHTML).to.contain('FRANK'); | ||
|
||
widget.setName('Jane'); | ||
|
||
expect(widget.el.innerHTML).to.contain('Jane'); | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/autotests/widgets-browser/sanity-check-template-entry-split/widget.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
setName: function(newName) { | ||
this.getEl('name').innerHTML = newName; | ||
} | ||
}; |
36 changes: 36 additions & 0 deletions
36
test/autotests/widgets-compilation/component-template-entry-split/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var template = require("marko/html").c(__filename); | ||
|
||
var renderer = require("./renderer"); | ||
|
||
var marko_widgets = require("marko/widgets/index"); | ||
|
||
module.exports = marko_widgets.r(renderer, template); | ||
|
||
var marko_registerWidget = marko_widgets.registerWidget, | ||
marko_widgetType = marko_registerWidget("/marko-test$1.0.0/autotests/widgets-compilation/component-template-entry-split/widget", function() { | ||
return require("./widget"); | ||
}), | ||
marko_widgetAttrs = marko_widgets.attrs, | ||
marko_helpers = require("marko/runtime/html/helpers"), | ||
marko_attr = marko_helpers.a, | ||
marko_attrs = marko_helpers.as, | ||
marko_loadTag = marko_helpers.t, | ||
w_widget_tag = marko_loadTag(require("marko/widgets/taglib/widget-tag")); | ||
|
||
function render(data, out) { | ||
w_widget_tag({ | ||
type: marko_widgetType, | ||
_cfg: data.widgetConfig, | ||
_state: data.widgetState, | ||
_props: data.widgetProps, | ||
_body: data.widgetBody, | ||
renderBody: function renderBody(out, widget) { | ||
out.w("<div" + | ||
marko_attr("id", widget.id) + | ||
marko_attrs(marko_widgetAttrs(widget)) + | ||
"></div>"); | ||
} | ||
}, out); | ||
} | ||
|
||
template._ = render; |
2 changes: 2 additions & 0 deletions
2
test/autotests/widgets-compilation/component-template-entry-split/index.marko
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div w-bind> | ||
</div> |
1 change: 1 addition & 0 deletions
1
test/autotests/widgets-compilation/component-template-entry-split/renderer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
1 change: 1 addition & 0 deletions
1
test/autotests/widgets-compilation/component-template-entry-split/widget.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters