emmetio / brackets-emmet

Emmet plugin for Brackets editor
http://emmet.io
MIT License
488 stars 187 forks source link

Specifying script tag with @src doesn't work #67

Open fourpastmidnight opened 9 years ago

fourpastmidnight commented 9 years ago

When specifying the following emmet abbreviation:

script[src="/lib/myJavaScript.js"]

it translates it to simply:

<script></script>

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/6672136-specifying-script-tag-with-src-doesn-t-work?utm_campaign=plugin&utm_content=tracker%2F311111&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F311111&utm_medium=issues&utm_source=github).
fourpastmidnight commented 9 years ago

Found the solution. Apparently, the current snippets.json file found at the official Emmet github repository has the following abbreviation:

"script": "<script !src=\"\">"

An older version of this file (supplied with my version of the Notepad++ Emmet plugin) contains the following rule, instead:

"script": "<script>"

Using this rule, it allows script[src="myFile.js"] to be expanded to <script src="myFile.js"></script>.

Also, something that is more handy (but not part of the official Emmet snippets.json is the following abbreviation which would replace the existing one:

"script:src": "<script src=\"{$1:script}.js\">"

Then, using script:src would expand to <script src="script.js"></script>, with script highlighted, awaiting your filename replacement.

For now, you can place this in your own snippets-*.json file. I found on Stack Overflow that in order to specify the extensions directory for this plugin on Windows machines, you need to replace all backslashes in the path with forward slashes (e.g. C:\MyExtensions\emmet would become C:/MyExtensions/emmet).