<br><br><div class="gmail_quote">On Tue, May 5, 2009 at 7:24 PM, Tomas Doran <span dir="ltr">&lt;<a href="mailto:bobtfish@bobtfish.net">bobtfish@bobtfish.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br></div>
Sorry for pointing out the obvious, but this is just perl:<br>
<br>
my $output = delete $c-&gt;res-&gt;{body};<br>
opem(FH, &quot;&gt;file&quot;) or die;<br>
print FH $output;<br>
close(FH);<br>
<br>
will do what you want...</blockquote><div><br>Hi Tom, <br><br>Thanks for your reply. <br><br>There are some things that aren&#39;t so obvious to me. Where would I place the code represented in your snippet?  I can&#39;t just hang it out in the main body of package hde::View::TTprint, since $c isn&#39;t available there. $c and $outfile *are* available in sub process, once the format for the forward statement is corrrect. So I *could* go ahead and perform the write-to-file operation there, but that seems a bit muddled. It seems to me the clearest place to write-to-file would be in sub output, but nothing seems to be showing up there. <br>
<br>Even so, I did try writing from sub process, and it gave me an error, which leads me to Question 2. <br>I&#39;m trying to follow Template Toolkit&#39;s documented API, which offers these configuration options, which I&#39;ve used in my TTprint base class:<br>
<br>OUTPUT       =&gt; \&amp;output,<br>OUTPUT_PATH  =&gt; [<br>        hde-&gt;path_to( &#39;root&#39;, &#39;static&#39;, &#39;published&#39; ),<br>    ],<br><br>Supposedly, the processed template output will be written to the output file relative to OUTPUT_PATH. But I get the error: <br>

<pre><font size="4"><code class="error">Caught exception in hde::View::TTprint-&gt;process &quot;Cannot open Test1.0.0/TOC.html for writing: No such file or directory&quot;</code></font></pre>
<br>BTW, this path already exists: ~/cat_work/hde/root/static/published/Test1.0.0<br><br>Please feel free to point out any obvious bit I&#39;ve botched.<br><br>/dennis<br><br>Code summary:<br><br>In controller:<br>my $path_and_file = &quot;<font><font size="4"><code class="error">Test1.0.0</code></font></font>
/TOC.html&quot;;<br>$c-&gt;forward( $c-&gt;view(&#39;TTprint&#39;), [ qq/$path_and_file/ ] );<br><br>In package hde::View::TTprint;<br>__PACKAGE__-&gt;config({<br>    TEMPLATE_EXTENSION =&gt; &#39;.tt2&#39;, <br>    INCLUDE_PATH =&gt; [<br>
        hde-&gt;path_to( &#39;root&#39;, &#39;src&#39; ),<br>        hde-&gt;path_to( &#39;root&#39;, &#39;lib&#39; ),<br>        hde-&gt;path_to( &#39;root&#39;, &#39;tt2&#39; )<br>    ],<br>    PRE_PROCESS  =&gt; &#39;config/main&#39;,<br>
    WRAPPER      =&gt; &#39;site/wrapper&#39;,<br>    OUTPUT       =&gt; \&amp;output,<br>    OUTPUT_PATH  =&gt; [<br>        hde-&gt;path_to( &#39;root&#39;, &#39;static&#39;, &#39;published&#39; ),<br>    ],<br>    ERROR        =&gt; &#39;error.tt2&#39;,<br>
    TIMER        =&gt; 0<br>});<br><br>my $outfile;<br><br>sub output {<br> my $output = shift;<br># Nothing shows up here<br>}<br><br>sub process {<br> my $self = shift;<br> my ($c, $outfile) = @_; # Not ignoring $c, so I can get debug stuff<br>
                                         # and delete body<br><br>  # $outfile = &#39;<font><font size="4"><code class="error">Test1.0.0</code></font></font>
/TOC.html&#39;;<br><br> $c-&gt;log-&gt;debug(&quot;In sub process&quot;); # does print<br> $c-&gt;log-&gt;debug(&quot;outfile: $outfile&quot;);<br><br> my $output = delete $c-&gt;res-&gt;{body};<br> open my $write_fh, &#39;&gt;&#39;, $outfile <br>
   or die &quot;Cannot open $outfile for writing: $!\n&quot;;<br> print $write_fh $output;<br> close $write_fh or warn &quot;Cannot close $outfile: $!\n&quot;;<br><br> return $self-&gt;next::method(@_);<br>}<br></div></div>