嵌入文档的空格键语法

Spacebars syntax for embedded documents

本文关键字:空格键 语法 文档      更新时间:2023-09-26

我有以下公司财务报表信息的模式:

FinancialsSchema = new SimpleSchema({
revenue: {
    type: Number,
    label: "Revenue",
    min: 0,
    optional: true
}
});
TimeSchema = new SimpleSchema({
period: {
    type: String,
    label: "Period",
    optional: true
},
financials: {
    type: FinancialsSchema,
    optional: true
}
});
CompanySchema = new SimpleSchema({
name: {
    type: String,
    label: "Company Name"
},
time: {
    type: TimeSchema,
    optional: true
}
});
Companies.attachSchema(CompanySchema);

我试图使用空格键在表格中显示LTM、FY+1和FY+2的收入数字。我的收藏中已经有以下内容,并通过控制台测试,收入和息税折旧及摊销前利润数字都已在LTM下获取。

    Companies.insert({
    name: "Example",
    sector: "Industrial",
    status: "Public",
    time: {
        period: "LTM",
        financials: {
            revenue: "200",
            ebitda: "100"
        }
    }
});

我本以为{周期("LTM").收入}}会起作用,但我尝试了几十种变化,无法将数字显示在表中。谢谢

您可能需要查看空格键自述,因为我认为{{period("LTM").revenue}}不是有效的空格键标记。函数是通过用空格将函数名与其参数分隔开来调用的,如:{{functionName arg1 arg2}}

为了得到你想要的东西,你需要首先获得感兴趣的共付额,可能需要一个返回Companies.findOne({period: "LTM"})的助手。

一旦您将感兴趣的公司作为数据上下文,您就需要使用{{time.financials.revenue}}{{time.financials.ebitda}}来获得收入和息税折旧摊销前利润值。按照您编写模式的方式,每个公司条目只能有一个收入和息税折旧及摊销前利润值,并且它们存储在time.financials对象中。