Meteor开发平台入门 互动版

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

模板中的注释

注释标签{{!}}用来在Spacebars模板中插入注释。在编译时Meteor将从生成的HTML代码中 清除这些注释。

≡ 单行注释

使用{{!创建单行注释,并使用}}结束注释:

<template name="demo">
  {{! Start of a section}}
  <div class="section">
    ...
  </div>
</template>

≡ 多行注释

使用{{!--创建多行注释,并使用--}}结束多行注释。在多行注释内可以使用{{}}

<template name="test">
  {{!-- This is a block comment.
  We can write {{foo}} and it doesn't matter.
  {{#with x}}This code is commented out.{{/with}}
  --}}
</template>

≡ 模板注释标签的位置限制

需要注意的是,模板注释标签只能出现在模板定义块内部。因此,下面的使用是错误的:

{{! 错误的注释标签位置}}
<template name="demo">...</template>

执行以下命令复位test应用、删除源文件:

~/test$ meteor reset↵ ~/test$ rm -rf \*↵

执行以下命令拷贝tpl-comments示例代码、运行并查看运行结果:

~/test$ cp ~/demos/tpl-comments/* .↵ ~/test$ meteor↵

理解并修改tpl-comments示例代码,通过练习掌握模板标签{{!}}的用法。