Modify value using a lambda

Let's say for an intance I have this template I wanted to render with :

var template = '{{#numbers}}'
             +     '{{#capitalize}}{{percentage}}{{/capitalize}} complete.\n'
             + '{{/numbers}}';

And I compile it with the ff:

var hello = hogan.compile(template);

var rendered = hello.render({
  numbers: [
    { percentage: .3 },
    { percentage: .6 },
    { percentage: .8 }
  ],
  capitalize: function() {
    return function(num) {
      // console.log(num);
      return num * 100;
    }
  }
})

console.log(rendered)

How do I get the number multiplied by 100 isntead of geting NaN?

NaN complete.
NaN complete.
NaN complete.

Also, when you uncomment the line above, num = {{percentage}} instead of the number itself.

Based on the response by @akonsu, here's an example on how you might get the value for a lambda in Hogan.js.

I have two helper functions in the example, manual and automatic, which can wrap around the lambda function definition depending on the desired behavior.

var source = '{{#numbers}}'
           +     'test1 = {{#test1}}{{percentage}}{{/test1}}\n'
           + '{{/numbers}}'
           + '{{#numbers}}'
           +     'test2 = {{#test2}}{{percentage}}{{/test2}}\n'
           + '{{/numbers}}';

var template = Hogan.compile(source);

var renderer = function(context) {
    return function(text) {
        return template.c.compile(text, template.options).render(context);
    };
};

var manual = function(lambda) {
    return function(text) {
        var render = renderer(this);
        return lambda.call(this, text, render);
    };
};

var automatic = function(lambda) {
    return manual(function(text, render) {
        return lambda.call(this, render(text));
    });
};

var rendered = template.render({
    numbers: [
        { percentage: .3 },
        { percentage: .6 },
        { percentage: .8 }
    ],
    test1: manual(function(text, render) {
        return render(text) * 100;
    }),
    test2: automatic(function(num) {
        return num * 100;
    })
});

console.log(rendered);

The output looks like this:

test1 = 30
test1 = 60
test1 = 80
test2 = 30
test2 = 60
test2 = 80

Here's a jsfiddle demonstrating the solution: http://jsfiddle.net/potatosalad/h5cU4/2/

Please note that this solution will not work with partials (if they are referenced from inside the lambda section).

The relevant code for Hogan.js 2.0.0 are lambda replace section and higher order functions.

I think this example is relevant: https://github.com/janl/mustache.js#functions. My guess is that this should help:

capitalize: function() {
  return function(text, render) {
    return render(text) * 100;
  }
}

a similar post: How to get the value when using Lambda in Hogan.js

capitalize: function(num) {
   return num * 100;
}

should work for you