velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Reck <apa...@recks.org>
Subject Re: Documentation for Directive
Date Wed, 27 Oct 2004 11:47:05 GMT
Ben wrote:
> Where can I find more information about Velocity Directive? I would
> like to write one but so far it doesn't work...
> 
> I would like to do something like this:
> 
> #useSomething("/WEB-INF/file.xml")
> #doSomething("nodeA")
> #doSomething("nodeB")
> #end
> 
> I created two directives, one for #useSomething (as BLOCK) and the
> other for #doSomething (as LINE). Somehow Velocity doesn't parse
> #doSomething. What should I do to make my #useSomething recognize
> #doSomething?
> 
> Thanks
> Ben

I guess you have note yet registered them in the velocity engine?

Look at
   http://cvs.apache.org/viewcvs.cgi/jakarta-velocity/src/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=HEAD
in the initializeDirectives() method how it loads the default and user directives.

Location of the resource defining the Default directives is in
   RuntimeConstants.DEFAULT_RUNTIME_DIRECTIVES
Which points to the file:
   http://cvs.apache.org/viewcvs.cgi/jakarta-velocity/src/java/org/apache/velocity/runtime/defaults/directive.properties?rev=HEAD

An example of setting up an user directive is in:
   http://cvs.apache.org/viewcvs.cgi/jakarta-velocity-dvsl/src/java/org/apache/tools/dvsl/DVSL.java?rev=HEAD
in the method setStylesheet(Reader) and line:
   ve.setProperty("userdirective", "org.apache.tools.dvsl.directive.MatchDirective");
But it should be possible to setup several user directives in the
velocity.properties file via the proper configuration-syntax use.

Another example of a configured user directory is in
   http://cvs.apache.org/viewcvs.cgi/jakarta-velocity/contrib/temporary/localdirective/


Maybe an initial instruction for custom user directives could be placed
in the Wiki?
   http://wiki.apache.org/jakarta-velocity/

Cheers,
Christoph


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


Mime
View raw message