Reproduction
Repo: accordproject/cicero-template-library PR #484, template src/fixed-interests.
grammar.tem.md (excerpt):
and monthly payments of {{% monthlyPaymentFormula(loanAmount,rate,loanDuration) as "K0,0.00" %}}
logic/logic.ts (excerpt):
function monthlyPaymentFormula(loanAmount: number, rate: number, loanDuration: number): number {
// ...
return monthly;
}
class FixedInterestsLogic extends TemplateLogic<ITemplateModel> { ... }
Driver:
const t = await Template.fromDirectory('./src/fixed-interests');
await new TemplateArchiveProcessor(t).draft(data, 'markdown', {});
Observed
{
nodeId: 'formula_d02c8642fa12d6ed08dea71f0af7a77b0c7893804d0b43b537eb18ea6f666463',
code: ' monthlyPaymentFormula(loanAmount,rate,loanDuration) as "K0,0.00" ',
errors: [{
category: 1, code: 2304,
renderedMessage: "Cannot find name 'monthlyPaymentFormula'.",
id: 'err-2304-684-21'
}]
}
The formula references a helper function defined in the template's logic/logic.ts, but TemplateArchiveProcessor.draft compiles the formula with a TypeScript context that doesn't include the template's user code. TemplateArchiveProcessor.trigger already does load the logic — only draft is affected.
Expected
draft() should compile inline formulas against the same TypeScript context as trigger(), so helper functions exported/defined alongside the TemplateLogic subclass are visible to formulas.
Versions
@accordproject/template-engine@3.0.1
@accordproject/cicero-core@0.26.0
@accordproject/concerto-core@4.1.0
Reproduction
Repo:
accordproject/cicero-template-libraryPR #484, templatesrc/fixed-interests.grammar.tem.md(excerpt):logic/logic.ts(excerpt):Driver:
Observed
The formula references a helper function defined in the template's
logic/logic.ts, butTemplateArchiveProcessor.draftcompiles the formula with a TypeScript context that doesn't include the template's user code.TemplateArchiveProcessor.triggeralready does load the logic — onlydraftis affected.Expected
draft()should compile inline formulas against the same TypeScript context astrigger(), so helper functions exported/defined alongside theTemplateLogicsubclass are visible to formulas.Versions
@accordproject/template-engine@3.0.1@accordproject/cicero-core@0.26.0@accordproject/concerto-core@4.1.0