I’ve been playing with this addon again for a while, and now I am wondering, how do I make closet evaluate the inlineValues when there are blockValues? Or is it not possible yet? I have a setup like this,
function parted(args) {
const {
tagname,
blockOptics = [],
blockApply,
inlineOptics = [],
inlineApply,
blankApply
} = args;
const filter = (args) => {
const { hasBlock, hasInline, inlineValues, blockValues, num } = args;
if (hasBlock && blockApply) {
return blockApply({ inlineValues, blockValues, num });
} else if (hasInline && inlineApply) {
return inlineApply({ inlineValues, num });
} else if (blankApply) {
return blankApply({ num });
} else {
return false;
}
};
return (registrar) => {
registrar.register(tagname, filter, { inlineOptics, blockOptics });
}
};
filterManager.install(
parted({
tagname: "gt",
inlineOptics: [closet.template.optics.separated({ sep: "::", max: 2, trim: true })],
inlineApply({ inlineValues }) {
const [left, right] = inlineValues.map((x) => parseFloat(x));
return left > right ? "1" : "0";
}
}),
parted({
tagname: "if",
inlineOptics: [closet.template.optics.separated({ sep: "::", max: 1, trim: true })],
blockOptics: [closet.template.optics.separated({ sep: "::", max: 1, trim: true })],
blockApply({ inlineValues, blockValues }) {
const [condition] = inlineValues;
const [block] = blockValues;
return condition.trim() == "1" ? block : "";
}
})
)
In the HTML, it would look like this then.
<!-- -->
[[#if::[[gt::[[genr::0, 10]]::5]]]]
<p>The number is greater than 5</p>
[[/if]]
<!-- -->
However, I would find that the condition parts are not being evaluated by closet. Is it possible?