title: freemarker functions vs macros
body: <p>Hello freemarkers gurus</p>
  
  <p>I understand that the difference between freemarker functions and macros is that macros can print to the output, but cannot return values, while functions can return values but cannot print to the output.</p>
  
  <p>Well, I am having a problem because I need both to print and return values:</p>
  
  <p>I am doing recursive tree exploration with freemarker and therefore I have a macro being called recurvively. As the tree is being explored , I need both to print node information to the output, but also compute and return statistics about the nodes explored ( for example the sum of a specific property of the nodes explored)</p>
  
  <p>If I use macro being called recurvively I can print node information but cannot return the statistics to the calling entity.</p>
  
  <p>If I use a function recursively called, I can return the statistics but cannot print node information on the output. </p>
  
  <p>One solution could be to explore the tree twice, once to print node informations and another to collect statistics, but I would hate to use this unelegant solution.</p>
  
  <p>Can someone propose a better solution?</p>
  
  <p>Thanks</p>