If you already have a template object (from the db) loaded, you can do:
my $ctx = $tmpl->context;
The error is because your context does not include a blog context --
it can't find $blog->server_offset because the blog is undefined. I
believe that using the method above will inherit the blog context of
the template in question, this avoiding this error.
-Mark
On Tue, Sep 2, 2008 at 5:25 PM, Michael Thomsen <mikerthomsen@...> wrote:
> I have a template file in a plugin that I need to compile and write
> the HTML to a separate directory. I've seen the following way to
> initialize a MT::Template::Context object to pass to
> MT::Template->build, but it causes an error. This is use in the docs:
>
> my $ctx = MT::Template::Context->new();
>
> Yet when I run that in a callback method attached to MT::Comment, I
> get the following error in my error log:
>
> died with: Can't call method "server_offset" on an undefined value at
> lib/MT/Template/ContextHandlers.pm line 10075.
>
> All I need to do is load the template, build it to HTML, and write it
> to a file. How should I setup the Context so that I can do this?
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>