Settings

Theme

Ask HN: Are there AST aware templating programs / snippets?

3 points by vaughands 4 years ago · 1 comment · 1 min read


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 4 years ago

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

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection