Template not working

Hello it’s my first topic !
I followed the tutorial for the todo list.
But I wanted to add features (and trying some things).
My problem is the template is not rendering.
Here is my code :

'test.js'
import { Template } from 'meteor/templating';
import "./test.html";


Template.body.helpers({
  tasks: [
    { text: "This is task 1" },
    { text: "This is task 2" },
    { text: "This is task 3" },
  ],
  
});

'test.html'
<template name="Entrainement_Home">
  <body>
    <div class="container">
      <header>
        <h1>Todo List</h1>
      </header>

      <ul>
        {{#each tasks}} {{> task}} {{/each}}
      </ul>
    </div>
  </body>
</template>

<template name="task">
  <li>{{text}}</li>
</template>

and my route:

FlowRouter.route("/entrainement", {
  name: "Entrainement.home",
  action() {
    BlazeLayout.render("App_body", { main: "Entrainement_Home" });
  },
});

I get the h1 Todo List, but not the list:

image

where is my mistake ?
Nico

Helpers are template specific. You defined yours for body but reference the helper in Entrainement_Home. I would put my money on the following to work

Template.Entrainement_Home.helpers({
  tasks: [
    { text: "This is task 1" },
    { text: "This is task 2" },
    { text: "This is task 3" },
  ],
  
});

I didn’t think helpers could be values, I thought they had to be functions?
Which means it would have to be this:

Template.Entrainement_Home.helpers({
  tasks() { 
    return [
      { text: "This is task 1" },
      { text: "This is task 2" },
      { text: "This is task 3" },
    ];
  },
});
~``
1 Like

Damnit. Of course, @coagmano is right

I thought I was about to learn something super useful haha

Ohhh thanks so much it works perfectly !!!