tags:

views:

340

answers:

2

I can't get NVelocity to initialize. I'm not trying to do anything complicated, so it's just fine if it initializes at the defaults, but it won't even do that.

This:

VelocityEngine velocity = new VelocityEngine();
ExtendedProperties props = new ExtendedProperties();
velocity.Init(props);

Results in: "It appears that no class was specified as the ResourceManager..."

So does this:

VelocityEngine velocity = new VelocityEngine();
velocity.Init();

I can find precious little documentation on what the properties should be, nor how to get it to initialize with the simple defaults. Can anyone point to a resource?

A lot of pages point back to this page:

http://www.castleproject.org/others/nvelocity/usingit.html

But this page skips over the (seemingly) most important point -- how to set the properties and what to set them to.

I just want to load a simple template from a file.

+2  A: 

Here's what I found out --

I was using the original NVelocity library, which hasn't had an update since 2003. I think it's a dead project.

I switched to the Castle Project version, and it's much easier -- in fact, it runs much like the examples on the page I linked to. It seems to set intelligent defaults for properties. I can initialize it without any properties set, but the template directory defaults to ".", so I generally set that one (do it before running "init").

To get the correct DLL, you need to download the latest NVelocity release (as of this writing it's 1.1).

Castle Project Download Page

Deane
A: 

Hi there,

i'm trying to use custom directives on NVelocity 1.1 from Castle Project, and it gives me an error saying that Could not resolve type 'namespace'. Is there an isue about it? Does anybody has already try to use it?

        ExtendedProperties props = new ExtendedProperties();
        props.AddProperty("input.encoding", "utf-8");
        props.AddProperty("output.encoding", "utf-8");
        props.AddProperty("userdirective", "(the namespace + name of the class)");
        engine.Init(props);

And the class is in the same project.

Thanks

Joel
I'll be honest -- I have given up on NVelocity. My understanding is that there hasn't been a new release since 2003. I've switched all my templating to the Spark View Engine.
Deane