简体   繁体   中英

How to add not html syntax snippet in Sublime with Emmet?

The old Emmet work fined, but now my Sublime has upgraded Emmet plugin to the latest version automatically, and the following snippets doesn't work anymore...

The latest Emmet can only accept HTML syntax on custom snippets

These snippets my seems odd, since these are my custom tag which will be convert into php code in Template Engine , so the code aren't HTML syntax.

For instance, when I type p1 and press tab , I want it give me <!--{if }--> :

{
    "config": {
        // Configure snippets/options for HTML syntax only.
        // For a list of supported syntaxes, check out keys of `syntax_scopes`
        // dictionary of `Emmet.sublime-settings`
        "html": {
            "snippets": {
                "p1": "<!--{if }-->",
                "l1": "<!--{/if}-->",
                "p2": "<!--{loop }-->",
                "l2": "<!--{/loop}-->",
                "p3": "<!--{eval }-->",
                "p4": "<!--{block }-->",
                "l4": "<!--{/block}-->",
                "else": "<!--{else}-->",
                "elif": "<!--{elseif }-->"
            }
        }
    }
}

New Emmet accepts snippet values as Emmet abbreviations (yep, a recursion) and plays better with native ST snippets. Thus, you should either add your snippets as native in ST, or if you still want to use Emmet for such snippets, you should write them as valid Emmet abbreviation. To output arbitrary text in Emmet abbreviation, you should write it as text node, eg wrap with { and } .

So, your snippet should look like this:

"p1": "{<!--{if }-->}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM