Open tomsontom opened 10 months ago
Hi Tom, thanks for this idea.
Instead of sticking to the classic append-based API:
Did you give the expandToNode
-based approach a try? That way you can write
function generateMethod(node: IndentNode, method: Method) {
expandToNode`
public ${method.name}(): ${method.returnType} {
${generateMethodBody(method)}
}
`;
}
provided
function generateMethodBody(method: Method): Generated {
return new ComponentGeneratorNode()....
}
Proposal
I'd like to propse to add another overload method
allowing me to directly pass a function instead of writing a closure.
Reason
While writing my code generator I found that I could have written more consise code if could directly pass a function to indent just to pass on a value/list of values to operate on.
Original:
With API addition:
If you think this API makes sense then I would implement and provide a PR.