Well, you have no choice than use macros. If you don't want to deal with the ast, you can still [work with strings](https://glot.io/snippets/eu2z63ru1r): import macros, strutils macro typeGen(tName, extra: untyped): untyped = var typeStr = """ type tName = object fname: string age: int""" typeStr = replace(typeStr, "tName", $tName) add(typeStr, "\l ") for f in extra: add(typeStr, repr(f[0]) & ':' & repr(f[1][0])) add(typeStr, "\l ") return parseStmt(typeStr) typeGen Test: a: bool b: byte
- Re: Code substitution with templates dataPulverizer
- Re: Code substitution with templates slimshady
- Re: Code substitution with templates LeuGim
- Re: Code substitution with templates dataPulverizer
- Re: Code substitution with templates LeuGim
- Re: Code substitution with templates Lando
- Re: Code substitution with templates slimshady
- Re: Code substitution with templates Udiknedormin
- Re: Code substitution with templates Arrrrrrrrr
- Re: Code substitution with templates dataPulverizer
- Re: Code substitution with templates Arrrrrrrrr
- Re: Code substitution with templates Araq
- Re: Code substitution with templates Udiknedormin
