On Thursday 14 February 2008 08:33:34 am Raymond Wan wrote: > So in an HTML file that will be processed by Mason, I call "myFunction > ()" and it says it is undefined. This surprised me since I indicated > that I am using myOwnFunctions in the handler with the "use" directive. > Is that not the way to do it? So, then I thought I should call > myFunction as: > > myOwnFunctions::myFunction () > > and that gave me an error. By accident, I typed: > > myHandler::myFunction () > > and that worked... I don't quite know why. I presume I have done a > mistake somewhere. Or is this how it should be?
Mason uses it's own namespace for the code it generates from your templates. So unless you have a "use lib...; use myOwnFunctions;" in your template, it won't have your functions in scope. This: > package myHandler; > use lib 'my Path'; > use myOwnFunctions; ## Located in "my Path" imports "myOwnFunctions" into the myHandler namespace, which is visible from Mason (either because you did a "use" or through Mason magic).