简单的 HTML 原子片段不起作用
Simple HTML atom snippet not working
我只是想在 Atom 文本编辑器中创建一个简单的 HTML 片段,并且我正在按照此 tutorial 中的说明进行操作。
我基本上将以下片段添加到我的 snippets.cson 文件中:
".source.html":
"HTML snippet":
"prefix": "spithtml"
"body": """<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Title here</title>
<link rel="author" href="humans.txt">
</head>
<body>
</body>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</body>
</html>
"""
上面的代码片段意味着每次我在我的文本编辑器中键入 spithtml
时,我希望 HTML 骨架出现。
上面的代码片段不起作用,实际上我在编辑器中收到一条错误消息:
C:\Users\myname\.atom\snippets.cson: unexpected :
这没有意义,因为我的 jQuery 的另一个片段工作得很好,就像这样:
".source.js":
"document ready":
"prefix": "$ready"
"body": """$(function(){
});"""
并且具有完全相同的语法。那么我缺少什么,如何在 Atom 中创建一个简单的 HTML 片段?令人惊讶的是,有很多关于如何使用原子包的文档,但没有关于如何创建简单的 HTML 片段的文档。
谢谢。
亚历克斯-z。
你的 body 属性缩进到很远,它应该像这样内联前缀:
".source.html":
"HTML snippet":
"prefix": "spithtml"
"body": """<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Title here</title>
<link rel="author" href="humans.txt">
</head>
<body>
</body>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</body>
</html>
"""
对于 html 个片段,您必须使用 .text.html 而不是 .source.html :
".text.html":
"HTML snippet":
"prefix": "spithtml"
"body": """<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Title here</title>
<link rel="author" href="humans.txt">
</head>
<body>
</body>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</body>
</html>
"""
我只是想在 Atom 文本编辑器中创建一个简单的 HTML 片段,并且我正在按照此 tutorial 中的说明进行操作。
我基本上将以下片段添加到我的 snippets.cson 文件中:
".source.html":
"HTML snippet":
"prefix": "spithtml"
"body": """<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Title here</title>
<link rel="author" href="humans.txt">
</head>
<body>
</body>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</body>
</html>
"""
上面的代码片段意味着每次我在我的文本编辑器中键入 spithtml
时,我希望 HTML 骨架出现。
上面的代码片段不起作用,实际上我在编辑器中收到一条错误消息:
C:\Users\myname\.atom\snippets.cson: unexpected :
这没有意义,因为我的 jQuery 的另一个片段工作得很好,就像这样:
".source.js":
"document ready":
"prefix": "$ready"
"body": """$(function(){
});"""
并且具有完全相同的语法。那么我缺少什么,如何在 Atom 中创建一个简单的 HTML 片段?令人惊讶的是,有很多关于如何使用原子包的文档,但没有关于如何创建简单的 HTML 片段的文档。
谢谢。
亚历克斯-z。
你的 body 属性缩进到很远,它应该像这样内联前缀:
".source.html":
"HTML snippet":
"prefix": "spithtml"
"body": """<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Title here</title>
<link rel="author" href="humans.txt">
</head>
<body>
</body>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</body>
</html>
"""
对于 html 个片段,您必须使用 .text.html 而不是 .source.html :
".text.html":
"HTML snippet":
"prefix": "spithtml"
"body": """<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Title here</title>
<link rel="author" href="humans.txt">
</head>
<body>
</body>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</body>
</html>
"""