[英]How can I replace the use of a perl module with a call to an external program?
[英]How do I use an arbitrary external program as a filter in a perl program?
我想使用當前C版的Fletcher Penny的Multi-markdown作為Template Toolkit中的過濾器。 我不清楚如何設置它。
目前我不是將TT稱為模塊,而是簡單地編寫使用tpage和ttree調用的模板。
Template-Toolkit過濾器實際上很容易編寫。
模塊:
package Template::Plugin::Filter::MultiMarkdown;
use strict;
use warnings;
our @ISA = 'Template::Plugin::Filter';
sub init {
my $self = shift;
$self->install_filter('markdown');
return $self;
}
sub filter {
my ($self, $text) = @_;
... Code that transforms $text and returns the transformed text ...
}
1;
用法:
[% USE Filter.MultiMarkdown %]
[% FILTER markdown %]...[% END %]
-or-
[% ... | markdown %]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.