我是Emmet的新手。尝试创建扩展为:
的自定义缩写<link rel="stylesheet" href="http://www.domain.com/path/CSstyles.css">
<link rel="stylesheet" href="http://www.domain.com/path/CDstyle2.css">
<link rel="stylesheet" href="http://www.domain.com/path/DEstyle.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
所以我可以轻松地为我经常工作的网站插入一组样式和脚本。
我在Sublime Text 3工作,然后去了Sublime&gt;偏好&gt;套餐设置&gt; Emmet&gt;设置 - 用户并添加以下内容作为起点:
{
"snippets": {
"html": {
"abbreviations": {
"lclinks": "<link rel=\"stylesheet\" href=\"http://www.domain.com/path/CSstyles.css\" />+<link rel=\"stylesheet\" href=\"http://www.domain.com/path/CDstyles.css\" />"
}
}
}
}
哪个有效,但没有扩展到第一个样式参考。我尝试使用+
替换n\t\
并获得相同的结果。我在网上找到了一个示例并插入了该示例,以查看是否有效,但它仍然没有超出第一个元素。我究竟做错了什么?文档here并未真正解决多个行代码段。
{
"snippets": {
"html": {
"abbreviations": {
"lclinks": "<div class=\"block\">\n\t<div class=\"text\">\n\t\t<h3>|</h3>\n\t\t<p></p>\n\t</div>\n</div>"
}
}
}
}
答案 0 :(得分:1)
在您的示例中,您正在使用abbreviations
部分实际上解析了单个元素 HTML标记,以将其用作构建输出的参考。您要做的是创建一个常规的文本片段。例如。一大堆任意代码。
如果您仔细阅读snippets.json部分,则会看到给定文件包含abbreviations
和snippets
部分,其含义不同,描述为here。
在您的示例中,您必须使用snippets
部分或使用abbreviations
部分中的aliases:
{
"snippets": {
"html": {
"abbreviations": {
"lclinks": "link[href=http://www.domain.com/path/CSstyles.css]+link[href=http://www.domain.com/path/CDstyle2.css]"
}
}
}
}