All,

On 6/20/22 13:54, Christopher Schultz wrote:
On 6/20/22 13:40, Christopher Schultz wrote:
I have a process where I'd like to use a global macro library but also allow the individual templates to override the macros if necessary.

My code looks something like this:


// == One-time setup
Properties props = new Properties();
props.setProperty("velocimacro.inline.allow", "true");
props.setProperty("velocimacro.inline.local_scope", "true");

/facepalm

I'm not sure how I messed-up the copy/paste of those settings, but they should have been:

props.setProperty("velocimacro.permissions.allow.inline", "true");
props.setProperty("velocimacro.permissions.allow.inline.local.scope", "true");

It's working as expected, now.

I spoke too soon. The "global" macros aren't being seen by the individual templates, now. I'm sure this is because I enabled local-scope and haven't explicitly-loaded the "global" macros as "global".

How do I do that? Probably /not/ by using VelocityEngine.evaluate() as I have here:

// == One-time setup
Properties props = new Properties();
props.setProperty("velocimacro.permissions.allow.inline", "true");
props.setProperty("velocimacro.permissions.allow.inline.local.scope", "true");
VelocityEngine ve = new VelocityEngine();
ve.init(props);

VelocityContext globalContext = new VelocityContext();

// Load the global macro template
engine.evaluate(globalContext, new NullWriter(), "VM_global_library", new InputStreamReader(...));

What do I need to do to create "global" macros when inline macros have been enabled?

-chris


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org

Reply via email to