Functions allow you to run groups of code within the template renderer.


Functions are assigned the same way that variables are assigned, as they are passed to the renderer data object.

Note: If a function returns anything, it should return a string otherwise the result will be converted to a string which means an object will display as [object Object]

const crypto = require('crypto')

Router.get('/', client => client.response.render('main.mix', {
  md5: (string) => crypto.createHash('md5').update(string).digest('hex'),
  emails: [ '', '', '' ]

Template access

A function is used in a similar way that a variable is used. So, it must be between double braces {{}} and it is formatted the same as a function in javascript. The function can also take parameters just like a javascript function.

    <each :="email in {{$emails}}">
      <img src="{{md5($email)}}">