mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes #208 - Marko v3: Re-introduce support for "import-var" in taglib
This commit is contained in:
parent
84de017839
commit
35e33aeb75
@ -67,6 +67,13 @@ function buildInputProps(node, context) {
|
||||
}
|
||||
});
|
||||
|
||||
tagDef.forEachImportedVariable(function(importedVariable) {
|
||||
let propName = importedVariable.targetProperty;
|
||||
let propExpression = importedVariable.expression;
|
||||
|
||||
inputProps[propName] = propExpression;
|
||||
});
|
||||
|
||||
if (node.body && node.body.length) {
|
||||
|
||||
if (tagDef.bodyFunction) {
|
||||
|
||||
@ -29,6 +29,7 @@ var Taglib = require('./Taglib');
|
||||
var propertyHandlers = require('property-handlers');
|
||||
var forEachEntry = require('raptor-util').forEachEntry;
|
||||
var loader = require('./loader');
|
||||
var markoCompiler = require('../');
|
||||
|
||||
function exists(path) {
|
||||
try {
|
||||
@ -368,7 +369,7 @@ TagHandlers.prototype = {
|
||||
throw new Error('Invalid "import-var": ' + require('util').inspect(varValue));
|
||||
}
|
||||
|
||||
importedVar.expression = expression;
|
||||
importedVar.expression = markoCompiler.defaultBuilder.parseExpression(expression);
|
||||
tag.addImportedVariable(importedVar);
|
||||
});
|
||||
},
|
||||
|
||||
20
test/fixtures/compiler/autotest/custom-tag-import-var/expected.js
vendored
Normal file
20
test/fixtures/compiler/autotest/custom-tag-import-var/expected.js
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
function create(__helpers) {
|
||||
var str = __helpers.s,
|
||||
empty = __helpers.e,
|
||||
notEmpty = __helpers.ne,
|
||||
escapeXml = __helpers.x,
|
||||
__renderer = __helpers.r,
|
||||
__tag = __helpers.t,
|
||||
test_body_function_renderer = __renderer(require("../../../taglib/scanned-tags/test-body-function/renderer"));
|
||||
|
||||
return function render(data, out) {
|
||||
__tag(out, test_body_function_renderer, {
|
||||
"name": "World",
|
||||
"myBody": function myBody(foo, bar) {
|
||||
out.w("This is the body content");
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
(module.exports = require("marko").c(__filename)).c(create);
|
||||
3
test/fixtures/compiler/autotest/custom-tag-import-var/template.marko
vendored
Normal file
3
test/fixtures/compiler/autotest/custom-tag-import-var/template.marko
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
<test-import-var name="World">
|
||||
This is the body content
|
||||
</test-import-var>
|
||||
7
test/fixtures/taglib/scanned-tags/test-import-var/marko-tag.json
vendored
Normal file
7
test/fixtures/taglib/scanned-tags/test-import-var/marko-tag.json
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"renderer": "./renderer",
|
||||
"import-var": {
|
||||
"foo": "data.foo",
|
||||
"bar": "data.bar"
|
||||
}
|
||||
}
|
||||
3
test/fixtures/taglib/scanned-tags/test-import-var/renderer.js
vendored
Normal file
3
test/fixtures/taglib/scanned-tags/test-import-var/renderer.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function(input, out) {
|
||||
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user