Skip to content
This repository was archived by the owner on Apr 4, 2019. It is now read-only.

Pruning of nodes through plugins / Walker #373

Open
zackthehuman opened this issue Jul 2, 2015 · 3 comments
Open

Pruning of nodes through plugins / Walker #373

zackthehuman opened this issue Jul 2, 2015 · 3 comments

Comments

@zackthehuman
Copy link

Hi. I have a use case where I need to remove nodes from the AST as part of a custom precompilation step. I want to walk the AST and remove certain helpers nodes, but there doesn't seem to be a way to do it (at least not through a plugin through ember-cli). Is this possible or does this need to be built out?

@mmun
Copy link
Collaborator

mmun commented Jul 2, 2015

@zackthehuman The current walker is pretty crappy and I have plans to write a new one in the style of babel plugins / estraverse. Basically the "visitor with replacement" pattern. Are you interested in working on that? Happy to chat about it in #dev-glimmer on the Ember community slack.

@mmun
Copy link
Collaborator

mmun commented Jul 2, 2015

Also the AST is not public yet so you might experience some breakage in the future. I'd like to have a similar API as ast-types, e.g. t.isHTMLComment(node).

@zackthehuman
Copy link
Author

Understood. This is something I would be interested in helping with for sure. At first I thought I could just use the AST Visitor from Handlebars but it turns out that wasn't the case :(. The nice thing about that visitor is it follows the "visitor with replacement" pattern you describe.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants