Another update: And we have the answer, null filters :p, next time i think i'll find a better example!
Update: Bah, missing something bloddy obvious!! :p
The template itself was sending it to sdtout, that's what i get for starting with an example file!
Took the obvious stdout statement out and it's kinda working except I seem to be getting a chunk of what i can only assume is debug info along with it!
Hi guys, I'm in the middle of adding an "image text" type to a cms I'm building in house, the gist of things is that is render's each of the pages out using template toolkit and then uses ssi to pull most of the data in, for the html stuff this works fine and the data is written to file as should be however when I try and render out the image text template it seems to be outputting the data to stdout (despite being told to put to file) which causes the rendering script to crash (since the ping header isn't a valid content type field :p)
Obviously being work i can't really put too much of the code up however here's the snippet of the template spec and how I'm calling process
In the conf file
# Webroot & base dir $conf->{'basePath'} = "/usr/local/www/cmstest"; # Template::Toolkit settings $conf->{'tt_include_path'} = "$conf->{'basePath'}/Templates"; $conf->{'tt_compile_dir'} = "$conf->{'basePath'}/ttwork"; $conf->{'tt_cache_size'} = "20"; $conf->{'tt_output_path'} = "$conf->{'basePath'}/website/"; # Default Template::Toolkit spec $conf->{'defTemplateSpec'} = { INCLUDE_PATH => $conf->{'tt_include_pat +h'}, COMPILE_DIR => $conf->{'tt_compile_dir +'}, CACHE_SIZE => $conf->{'tt_cache_size' +}, POST_CHOMP => 2, PRE_CHOMP => 2, TRIM => true };
In the render script (which pulls in the conf file at the top)
my $templateSpec = $conf->{'defTemplateSpec'}; $templateSpec->{'OUTPUT_PATH'} = $conf->{'tt_output_path'};
And in the render library ($templateSpec being passed through to the render_node sub this is from)
my $nodeTemplate = Template->new($templateSpec); $nodeTemplate->process( "node/" .$node->{$nodeId}->{'template'}, $vars, "$nodeId.html" ) || push @errors, $nodeTemplate->error();
And the template itself
[% nodes.$node.data.textwidth = nodes.$node.data.width %] [% USE gd = GD.Image(nodes.$node.data.width,nodes.$node.data.height); + %] [% gd.trueColor(1); %] [% USE wrapbox = GD.Text.Wrap(gd, line_space => 4, text=> nodes.$node.data.text, ); %] [% wrapbox.font_path(basePath _ "/Templates/fonts"); %] [% wrapbox.set_font(nodes.$node.data.font,nodes.$node.data.tsize); %] [% bounds = wrapbox.get_bounds(0,0) %] [% nodes.$node.data.height = bounds.3 %] [% xpos = (nodes.$node.data.width - nodes.$node.data.textwidth) %] [% IF xpos >0 %] [% xpos = xpos / 2; %] [% END %] [% USE gd2 = GD.Image(nodes.$node.data.width,nodes.$node.data.height) +; %] [% gd2.trueColor(1); %] [% bgcol = gd2.colorAllocate(nodes.$node.data.bgcol.r, nodes.$node.dat +a.bgcol.g, nodes.$node.data.bgcol.b); %] [% gd2.fill(1,1,bgcol); %] [% IF nodes.$node.data.trans == "1" %] [% gd2.transparent(bgcol); %] [% END %] [% fgcol = gd2.colorAllocate(nodes.$node.data.fgcol.r,nodes.$node.data +.fgcol.g,nodes.$node.data.fgcol.b); %] [% USE wrapbox2 = GD.Text.Wrap(gd2, line_space => 4, color => fgcol, text=> nodes.$node.data.text, ); %] [% wrapbox2.font_path(basePath _ "/Templates/fonts"); %] [% wrapbox2.set_font(nodes.$node.data.font,nodes.$node.data.tsize); %] [% wrapbox2.set(align => 'left', width => nodes.$node.data.textwidth); + %] [% wrapbox2.draw(xpos, 0); %] [% gd2.png | stdout(1); %]
I've checked the template to make sure I've not worked any errors into it and it seems fine (I've a preview script that uses it).
So, am i missing something glaringly obvious or is this a bug ?
In reply to Template::GD oddities by MiggyMan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |