HTML 条评论的 Atom 代码段
Atom snippet for HTML comments
我在编写代码片段时浏览了 atom 文档:
但是,文档对于我面临的问题来说太简单了。我想编写一个片段,它会自动创建一个包含 HTML 元素的 class 名称的注释。让我们看一个例子:
<div class="first-class another-class">
...
</div><!-- first-class another-class -->
我想要一个片段,它会在我键入时自动创建包含 "first-class another-class" 的评论,例如,在 div 的结束标记之后输入 "comm" 并按 TAB。这甚至可以通过片段实现吗?
您的工作流程不允许您与前面的标签一起创建评论吗?在这种情况下,您可以使用这样的东西:
'.text.html':
'Snippet Name':
'prefix': 'comm'
'body': """
<div class="${1:classes}">
${2:<!-- your markup here -->}
</div><!-- ${1:classes} -->
"""
或更高级:
'.text.html':
'div+comment':
'prefix': 'comm'
'body': """
<${1:div} ${2:class="${3:classes}"}>
${4:<!-- your markup here -->}
</${1:div}>${2:<!-- ${3:classes} -->}
"""
将此文件另存为(例如comm.cson
)并将其放入包目录中。
我在编写代码片段时浏览了 atom 文档:
但是,文档对于我面临的问题来说太简单了。我想编写一个片段,它会自动创建一个包含 HTML 元素的 class 名称的注释。让我们看一个例子:
<div class="first-class another-class">
...
</div><!-- first-class another-class -->
我想要一个片段,它会在我键入时自动创建包含 "first-class another-class" 的评论,例如,在 div 的结束标记之后输入 "comm" 并按 TAB。这甚至可以通过片段实现吗?
您的工作流程不允许您与前面的标签一起创建评论吗?在这种情况下,您可以使用这样的东西:
'.text.html':
'Snippet Name':
'prefix': 'comm'
'body': """
<div class="${1:classes}">
${2:<!-- your markup here -->}
</div><!-- ${1:classes} -->
"""
或更高级:
'.text.html':
'div+comment':
'prefix': 'comm'
'body': """
<${1:div} ${2:class="${3:classes}"}>
${4:<!-- your markup here -->}
</${1:div}>${2:<!-- ${3:classes} -->}
"""
将此文件另存为(例如comm.cson
)并将其放入包目录中。