kiko91
1
My code :
Template.home.helpers({
contents() {
var contentArray = [];
var content1 =
{
‘contentName’: ‘test1’,
‘contentSize’: ‘test1’,
‘contentType’: ‘test1’,
};
var content2 =
{
‘contentName’: ‘test2’,
‘contentSize’: ‘test2’,
‘contentType’: ‘test2’,
};
contentArray.push(content1);
contentArray.push(content2);
return contentArray;
}
});
How can I display my “contents” in HTML page ?
{{#each contents}}
{{this.contentName}} |
{{this.contentSize}} |
{{this.contentType}} |
{{/each}}
This doesn’t work for me
Try this:
{{#each contents}}
{{contentName}}
{{contentSize}}
{{contentType}}
{{/each}}
kiko91
3
I try it ! Doesn’t work …
@jhuenges is correct. But so are you . Either of those forms will work, as will this:
<template name="home">
{{#each content in contents}}
{{content.contentName}}
{{content.contentSize}}
{{content.contentType}}
{{/each}}
</template>
So, I wonder if you have got a template “home” and if you have invoked it ({{> home}}
)?
kiko91
5
It is working now ! I thought the problem is from this code or I missed something But it’s okay now thank you
1 Like