Lets say I have a definition of a template in a html file.
假设我在html文件中定义了模板。
<template name="myTemplate">
Now in javascript I want to get the value that is name in template by referencing the Template itself to avoid typing mistakes and to allow intellij ide ctrl clicking of the template to take me to the template.
现在在javascript中我希望通过引用模板本身来获取模板中名称的值,以避免键入错误并允许intellij ide ctrl单击模板以将我带到模板。
I want something like.
我想要类似的东西。
let stringValueOfTemplateName = Template.myTemplate.name
Instead of having to do
而不是必须这样做
let stringValueOfTemplateName = "myTemplate"
Is there any way to access the name?
有没有办法访问该名称?
2 个解决方案
#1
1
Template.captureView.viewName.replace('Template.',''))
or
Template.instance().view.name.replace('Template.',''))
#2
1
Try
let stringValueOfTemplateName = Template.instance().view.name.replace('Template.', '');
#1
1
Template.captureView.viewName.replace('Template.',''))
or
Template.instance().view.name.replace('Template.',''))
#2
1
Try
let stringValueOfTemplateName = Template.instance().view.name.replace('Template.', '');