sublime 如何自定义标签包裹ejs内容

比如我想把Hello world包裹成<%= Hello world %>

请问大家该如何实现呢?emmet似乎只能包裹内置的html元素,而sublime的snippet只能预先生成片段再在片段内填写

ejs实际编写过程中,写<% %>这样的符号效率很低

<ul>
        <% users.forEach(users=>{ %>            
        <% }) %></ul>

请大家集思广益,看有没有提高编写这种东西的效率~感谢


慕娘9325324
浏览 722回答 2
2回答

jeck猫

如对应的 snippet 文件&nbsp;ejs_insert_tags.sublime-snippet(快捷键&nbsp;= + tab):<snippet> &nbsp;&nbsp;<content><![CDATA[<%${1:=&nbsp;}${2:$SELECTION}&nbsp;%>$0]]></content> &nbsp;&nbsp;<description><![CDATA[<%(=)&nbsp;'insert&nbsp;ejs&nbsp;tags'&nbsp;%>]]></description> &nbsp;&nbsp;<!--&nbsp;Optional:&nbsp;Set&nbsp;a&nbsp;tabTrigger&nbsp;to&nbsp;define&nbsp;how&nbsp;to&nbsp;trigger&nbsp;the&nbsp;snippet&nbsp;--> &nbsp;&nbsp;<tabTrigger>=</tabTrigger> &nbsp;&nbsp;<!--&nbsp;Optional:&nbsp;Set&nbsp;a&nbsp;scope&nbsp;to&nbsp;limit&nbsp;where&nbsp;the&nbsp;snippet&nbsp;will&nbsp;trigger&nbsp;--> &nbsp;&nbsp;<scope>text.html</scope></snippet>对应的 key binding(快捷键:ctrl + shift + .):[{&nbsp;&nbsp;"keys":&nbsp;["ctrl+shift+."],&nbsp;&nbsp;"command":&nbsp;"insert_snippet",&nbsp;&nbsp;"args":&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;"name":&nbsp;"Packages/User/ejs_insert_tags.sublime-snippet" &nbsp;&nbsp;} }]
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Node.js