Passing functions as data context to Template.dynamic

Hello everybody!
I’m passing a function as a property to a data context with a dynamic template just like this:

    getDynamicData() {
        return {
             someField: 'hello',
             aFunction: () =>  {
                 console.log('hello world');
<template name="example">
    {{> Template.dynamic template="anotherTemplate" data=getDynamicData }}

The problem is that the function gets called immediatly, instead of being passed as a value.
This function is a callback I want to pass to the “anotherTemplate” and call it inside this template.

Please help!

It shouldn’t be called automatically - are you sure you aren’t inadvertently calling it in anotherTemplate? Can you post your anotherTemplate template?

I’m calling inside a click event on the “anotherTemplate” and it’s called before its even rendered, but the click event wasn’t called.

Can you post a fuller example?

Okey this is the “anotherTemplate” code:

<template name="anotherTemplate">
    {{> oneMoreTemplate aFunction=this.aFunction}} <- Here is the problem
<template name="oneMoreTemplate">
    <span class="toClick">click me</span>
    'click .toClick': function(event, template) {;

The error i get:

aFunction is not a function

aFunction is actually undefined

Now I get it, when I pass it like this, it’s being called because SpaceBars call functions without ().
I need to create a helper that returns this function as a value.