1

I'm new and struggling with velocity templates. I have few templates in hand with lots of macros in it.

// file b.vm
#macro (bmacro)
 from b macro
#end

// file a.vm
#parse("//temp//b.vm")
from a
#bmacro()

My expectation is to get

from a
from b macro

however, I am getting only "from a" as outcome. But when I place any static text outside bmacro, it is getting along.

By the way, I'm using NVelocity from castle project.

Thanks

Krishna Sarma
  • 1,852
  • 2
  • 29
  • 52

1 Answers1

1

The macro doesn't work because NVelocity (and its ancestor Velocity) determine if #bmacro is a directive or macro at parse time, while the #bmacro macro gets discovered at runtime as it jumps into the other template, and so it is passed through as text.

I answered this other question with a detailed answer a few months ago that had the same problem: macros not rendering in NVelocity

Community
  • 1
  • 1
Jonathon Rossi
  • 4,149
  • 1
  • 22
  • 32