In reply to @ollicron_53732 "That would be very": 1) Figure out what code you want to generate and write yourself a small implementation for an example 2) Look at what the NimNode pattern looks like using dumpAstGen/dumpTree. This is the tree of NimNodes we want to build (though we might be able to shortcut things by using genAst or similar utilities) 3) Define the shape of the "code" you want to accept in your macro 4) Write your macro but split it into 3 steps: validate - extract data - generate code 4.1) Validate: Write yourself a proc that accepts the NimNode and then checks that it is the shape that you expect and has all the information it needs 4.2) Extract Data: If necessary, extract the data from the NimNode into some object type that is easier to work with (if you're familiar with webdev, this object would be similar to the context object you typically have when generating HTML in SSR) 4.3) Generate Code: Ideally you can get away with just having one huge genAst statement into which you dump the contents of your context object from 4.2).