2018-02-07 11:46:19 +01:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const options_1 = require("./options");
|
|
|
|
function computeParts(parts, data = {}) {
|
2018-02-09 15:01:09 +01:00
|
|
|
if (parts === undefined || parts.length === 0)
|
2018-02-07 11:46:19 +01:00
|
|
|
return '';
|
|
|
|
return computePart(parts[0], data) + computeParts(parts.slice(1), data);
|
|
|
|
}
|
|
|
|
exports.computeParts = computeParts;
|
|
|
|
function computePart(part, data = {}) {
|
|
|
|
if (options_1.isRender(part))
|
|
|
|
return part;
|
|
|
|
else
|
|
|
|
return computePartFunction(part, data);
|
|
|
|
}
|
|
|
|
function computePartFunction(func, data = {}) {
|
|
|
|
if (options_1.isRender(func))
|
|
|
|
return func;
|
|
|
|
else {
|
|
|
|
const ret = func(data);
|
|
|
|
if (options_1.isRender(ret))
|
|
|
|
return ret;
|
|
|
|
else
|
|
|
|
return computeParts(ret, data);
|
|
|
|
}
|
|
|
|
}
|