gpt4 book ai didi

meteor - 在 meteor 中与字符串连接的变量

转载 作者:行者123 更新时间:2023-12-02 04:42:20 25 4
gpt4 key购买 nike

有什么方法可以在 Meteor 模板中将字符串与变量连接起来,就像其他框架一样,即在角度 {{'my name is' +name}} 我知道它可以通过 helper 。但是我找到了更好的方法或者至少是更简单的方法来实现这一点。我也试过 value="'my name is' {{name}}" 但它总是将名称作为字符串并且输出是 "my name is name"

编辑:这是我在模板中的原始代码行

<template name="editCategory">
<!-- Page heading -->

{{> pageHeading title="my name is {{name}}" category='Catalog' }}


</template>

名称值来自这里

Template.editCategory.helpers({
name: function() {
return this.translation[Object.keys(this.translation)[0]].name;
}
});

我已经检查了模板中的名称值 {{name }} 并且工作完美

最佳答案

您可以使用 Blaze .下面是一个示例助手,

{{> post}}

Template.foo.helpers({post: function () {
return Template[this.postName];
});

template_registerhelper 的文档

编辑:

还有之前提交的答案here

关于meteor - 在 meteor 中与字符串连接的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36396754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com