Perhaps I'm making things too difficult, but I've googled the maillist 
and searched the badger book, but I'm still not getting it.

I have a wrapper which I want to (if the file type is right) run my 
"content" through an external program, specifically it is a perl script 
that compresses my css files.

Run standalone, I can use this script as a typical unix filter:

     compress_css.pl big.css > small.css
or
     cat big.css | compress_css.pl > small.css

Now I want to wire this into my TT code.  I should add that I generate 
static files, and all my website is generated by ttree.

In wrapper.tt I have:

[% SWITCH type %]
     [% CASE 'text' %]
         content
     [% CASE 'css' %]
         [% PERL %]
        my $txt = $context->stash()->get('content');
        open(FH, "|perl lib/compact_css.pl") or die "Couldn't open css 
compressor";
        print FH $txt;
        close(FH);
         [% END %]
     [% CASE %]
         content WRAPPER html_wrapper.tt
[% END %]

CSS goes through my compressor, but the stdout isn't captured, it just 
spews to the screen and is gone.  I've used PERLOUT to capture the 
output of an external perl program before, but in those cases I wasn't 
trying to pipe in anything.

I guess I could write $txt to a temp file, then run my filter, then 
delete the tmp, but I was hoping for something more elegant.

Thanks in advance for any suggestions on the right way to do this.

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to