I am a newbie for blaze and I am confused for this: n-${classname}
.
Please help me!
Can you provide a little more context? Where does this line appear?
Template.Todos_item.helpers({
checkedClass(todo, options) {
const classname = options.hash.classname || ‘checked’;
if (todo.checked) {
return classname;
} else if (options.hash.noClass) {
return no-${classname}
;
}
}
});
Using backticks to enclose strings is an ES6 language feature allowing string templating. The expression:
`n-${classname}`
is exactly equivalent to
"n-" + classname
However, the backtick method has a number of useful properties, including preserving newlines. Check the Mozilla Template Literals doc for more info.
6 Likes
I got it, thanks very much!