mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Moved handling of String includes into the core tag
This commit is contained in:
parent
7dc0bf3eeb
commit
9e4a638c51
@ -5,6 +5,8 @@ module.exports = function include(input, out) {
|
|||||||
if (target) {
|
if (target) {
|
||||||
if (typeof target === 'function') {
|
if (typeof target === 'function') {
|
||||||
target(out, arg);
|
target(out, arg);
|
||||||
|
} else if (typeof target === 'string') {
|
||||||
|
out.text(target);
|
||||||
} else if (typeof target === 'object') {
|
} else if (typeof target === 'object') {
|
||||||
if (target.renderBody) {
|
if (target.renderBody) {
|
||||||
target.renderBody(out, arg);
|
target.renderBody(out, arg);
|
||||||
@ -12,6 +14,8 @@ module.exports = function include(input, out) {
|
|||||||
target.renderer(arg, out);
|
target.renderer(arg, out);
|
||||||
} else if (target.render) {
|
} else if (target.render) {
|
||||||
target.render(arg, out);
|
target.render(arg, out);
|
||||||
|
} else if (target.safeHTML) {
|
||||||
|
out.write(target.safeHTML);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid include target: ' + target);
|
throw new Error('Invalid include target: ' + target);
|
||||||
|
|||||||
1
test/autotests/render/include-safeHTML/expected.html
Normal file
1
test/autotests/render/include-safeHTML/expected.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<strong>Hello!</strong>
|
||||||
2
test/autotests/render/include-safeHTML/template.marko
Normal file
2
test/autotests/render/include-safeHTML/template.marko
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var html = { safeHTML: '<strong>Hello!</strong>' };
|
||||||
|
<include(html)/>
|
||||||
1
test/autotests/render/include-safeHTML/test.js
Normal file
1
test/autotests/render/include-safeHTML/test.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
exports.templateData = {};
|
||||||
1
test/autotests/render/include-string/expected.html
Normal file
1
test/autotests/render/include-string/expected.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<script>Hello</script>
|
||||||
2
test/autotests/render/include-string/template.marko
Normal file
2
test/autotests/render/include-string/template.marko
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var text = '<script>Hello</script>';
|
||||||
|
<include(text)/>
|
||||||
1
test/autotests/render/include-string/test.js
Normal file
1
test/autotests/render/include-string/test.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
exports.templateData = {};
|
||||||
@ -5,9 +5,7 @@ var getElementById = require('../util').$__getElementById;
|
|||||||
module.exports = function include(input, out) {
|
module.exports = function include(input, out) {
|
||||||
var target = input._target;
|
var target = input._target;
|
||||||
|
|
||||||
if (typeof target === 'string') {
|
if (target != null) {
|
||||||
out.text(target);
|
|
||||||
} else if (target) {
|
|
||||||
normalInclude(input, out);
|
normalInclude(input, out);
|
||||||
} else if (getElementById) {
|
} else if (getElementById) {
|
||||||
var elId = input._elId;
|
var elId = input._elId;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user