Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

sublimetext3 - 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 }-->"
            }
        }
    }
}
question from:https://stackoverflow.com/questions/66066391/how-to-add-not-html-syntax-snippet-in-sublime-with-emmet

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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, e.g. wrap with { and }.

So, your snippet should look like this:

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...