获取模板Meteor的HTML内容

获取模板Meteor的HTML内容,meteor,Meteor,如何获取模板的html内容?例如,我有以下模板: <template name="test"> <div id="example"> <strong>This is a test.</strong> </div> <button id="btn">Get</button></template> 这是一个测试。 得到 我需要一个事件点击按钮来捕获div示例的HTML内容。有可能吗?您可以使

如何获取模板的html内容?例如,我有以下模板:

<template name="test">
<div id="example">
    <strong>This is a test.</strong>
</div> <button id="btn">Get</button></template>

这是一个测试。
得到
我需要一个事件点击按钮来捕获div示例的HTML内容。有可能吗?

您可以使用(已内置在meteor中)进行此操作


如果您使用Template.test.events分配单击事件,您应该在“this”中拥有模板描述的所有数据。

从Meteor 1.x开始,您可以使用。它以字符串形式返回给定模板的HTML

var html = $('#example').html();