HACKER Q&A
📣 vaughands

Are there AST aware templating programs / snippets?


When writing tests and some Angular code, I often have to write some boilerplate (import X, create a Y to do Y, add a function, implement an interface)

One such example is this: https://stackoverflow.com/a/42490431/1554844

I would love to be able to describe in a snippet file:

1. Import OnInit, OnDestroy if it's not already 2. Implement the interface 3. Add those methods if needed, add the code + field

Is there a tool that can do / run generic AST transforms with some easy to use templating language / DSL?


  👤 verdverm Accepted Answer ✓
I've been building a tool called hof (https://github.com/hofstadter-io/hof) that can do this and much more.