Has anyone created a codemod for ember-bootstrap or at least one that works on template files?

We’re converting a large app from using the bootstrap jQuery plugins to use ember-bootstrap instead. There are hundreds of tooltips and other bootstrap components littered throughout the code base, so we wanted to try using a codemod to automate converting the files if possible.

I’ve seen lots of examples of how to us jscodeshift to modify the .js files in an ember app, but haven’t found any examples of codemods that work on .hbs templates. I was able to use w/ ASTExplorer to parse .hbs content and remove things like data-toggle="tooltip":

However, I’m not sure how to add new handlebars nodes like {{#bs-tooltip}}.

Any pointers in the right direction would be greatly appreciated.

Last I knew, there’s not a handlebars AST printer that does a good job of preserving formatting. That is the main blocker to writing HBS code mods.

(People modify handlebars AST often, but it’s usually as a transform that runs at build time, so that the code it emits goes straight into the template compiler, not back out into your repo.)

1 Like

I know this thread is far too old, but I stumbled upon this by coincidence, so for the record in case someone reads this again:

2 Likes