Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make js2-minor-mode work in html files by specifying what parts of code to parse #494

Open
JJPandari opened this issue May 2, 2018 · 1 comment

Comments

@JJPandari
Copy link

JJPandari commented May 2, 2018

I tried to use js2-refactor in web-mode(html file) and were told to just turn on js2-minor-mode but the file content has to be just js code.

The common situation where I want to use web-mode: an html or server side template file, with javascript codes wrapped in <script> tags. js2/js2r doesn't work unless we extract the js codes for js2-mode to parse them alone, not the whole buffer. Is it a good idea to maybe have some configs like (setq js2-js-code-surrounding-tags '("<script>" "</script>")) (setq js2-js-code-matcher "<script>\\(.+\\)<\\/script>") (don't mind my elisp regex error if there's any), so users can easily use all js2 and js2r goodies in html files and so?

This feature shouldn't be too hard to implement with some with-temp-buffer thing I guess? But still a bit beyond my reach and it may fit in js2 so here's this issue. Also this may not cover all server side template files like var <?=$name?> = "<?=$value?>"; (<?=$var?> is the .php file interpolation syntax) as js2 will have parse errors on them, but covering html files should still be quite a step forward.

This idea came up when I read this js2-refactor issue where I duplicated most of the above comment.

@dgutov
Copy link
Collaborator

dgutov commented May 2, 2018

Ultimately, it should be possible, but I'm not sure what the best implementation approach will be.

I'd take a look at a patch, that's all I can promise, unfortunately.

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

No branches or pull requests

2 participants