How does Jade use custom methods?

  node.js, question

For example, I now have a method for output format conversion:

function anonymousName(name) {
 var anm = name.substring(0, 1);
 var star = '*',i;
 for(i=1;  i<name.length-1;  I plus)
 Star plus =' *';
 Anm = anm plus star;
 return anm;
 * anonymousName ('ma yun')
 * > horses *

How to call this method in jade?

-var name =' ma yun'
 p #{anonymousName(name)}

Obviously this would be a mistake.
How can I make my method effective?

Jade’s custom JS code or JSON data are preferably compressed into one line.
In addition, using the equal sign to assign value will prevent you from reading the value of name with # {}

-function anonymousName(name) {var anm=name.substring(0,1);  var star='*',i;  for(i=1;  i<name.length-1;  I plus) {if(i==5){break}star plus ='*'}anm=anm plus star;  return anm;  };
 -var name =' ma yun'
 p= anonymousName(name)

Successfully output results

Horse *