Wednesday, June 23, 2021

Text templates, code generation

 Python: wheezy.template

@def indent(lines, sep):
@sep.join(lines.split('\n'))
@end

@def body():
function body;
statement2;
@end

@def func(name):
    func @name {
        @body()
        @indent('1\n2\n3\n', '\n        ')
        @indent(body(), '\n        ')
    }
@end


@func('hello')


Java: StringTemplate4

No comments: