[SP-pm] Inserindo variável no pro_process

Daniel de Oliveira Mantovani daniel.oliveira.mantovani at gmail.com
Fri Dec 12 10:10:58 PST 2008


2008/12/12 Andre Carneiro <andregarciacarneiro em gmail.com>

>
> 1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
> 2<html>
> 3<head>
> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
>
> 5  <link rel="stylesheet" href="../style.css" />
> 6 <title>[% PROCESS titulo %]</title>
> 7 </head>
>
> Olhe a linha 6 agora. Isso q você quer saber? Carinha... se for isso, favor fazer RTFM aqui: http://template-toolkit.org/docs/manual/Syntax.html
>
>
Na verdade essa parte é certa, agora só faltar fazer "setar" a variável para
o pre_process agora.

>
>
> Cheers!
>
> 2008/12/12 Daniel de Oliveira Mantovani <
> daniel.oliveira.mantovani em gmail.com>
>
>> Só corrigindo:
>> Inserindo variável no pro_process
>> Inserindo variável no pre_process
>>
>> head.info
>> header.info
>>
>>
>> 2008/12/12 Daniel de Oliveira Mantovani <
>> daniel.oliveira.mantovani em gmail.com>
>>
>> Minha dúvida é a seguinte, eu tenho um arquivo que chama head.info:
>>> <code>
>>>
>>> 1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
>>> 2<html>
>>> 3<head>
>>> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
>>> 5  <link rel="stylesheet" href="../style.css" />
>>> 6 <title>[% title %]</title>
>>> 7 </head>
>>>
>>> </code>
>>> Na linha 7 eu quero por o título, mas não sei como faço isso incluindo
>>> uma variável em um pré processo, olha meu código:
>>> <code>
>>>
>>>  1 #!/usr/bin/perl
>>>   2
>>>   3 BEGIN {
>>>   4     my $homedir = ( getpwuid($>) )[7];
>>>   5     my @user_include;
>>>   6     foreach my $path (@INC) {
>>>   7         if ( -d $homedir . '/perl' . $path ) {
>>>   8             push @user_include, $homedir . '/perl' . $path;
>>>   9         }
>>>  10     }
>>>  11     unshift @INC, @user_include;
>>>  12 }
>>>  13
>>>  14
>>>  15 use strict;
>>>  16 use warnings;
>>>  17 use Template;
>>>  18 use CGI qw/ :standard/;
>>>  19
>>>  20 # some useful options (see below for full list)
>>>  21 my $config = {
>>>  22 INCLUDE_PATH => '/home/redrosec/public_html/cgi-bin/',  # or list ref
>>>  23 INTERPOLATE  => 1,   # expand "$var" in plain text
>>>  24 POST_CHOMP   => 1,   # cleanup whitespace
>>>  25 PRE_PROCESS  => 'header.info',# prefix each template
>>>  26 EVAL_PERL=> 1,   # evaluate Perl code blocks
>>>  27 };
>>>  28
>>>  29
>>>  30 my $vars = {
>>>  31    'title' => "Hello World"
>>>  32 };
>>>  33 # create Template object
>>>  34 my $template = Template->new($config, $vars);
>>>  35
>>>  36 # specify input filename, or file handle, text reference, etc.
>>>  37 my $input = 'begin.tt';
>>>  38
>>>  39 # process input template, substituting variables
>>>  40 $template->process($input) || die $template->error();
>>>  41
>>>  42 print<<'GOOGLE';
>>>  43 <p align=center>
>>>  44 <script type="text/javascript"><!--
>>>  45 google_ad_client = "pub-6551982862465531";
>>>  46 /* 728x90, criado 04/12/08 */
>>>
>>> 34,29      Início
>>> </code>
>>>
>>> Eu quero inserir a variável na linha 31, dentro do header.info e não
>>> tenho ideia de como fazer.
>>> --
>>> Procuro emprego C.V:
>>> http://danielmantovani.awardspace.com/
>>>
>>> print
>>> "\x54\x68\x65\x20\x53\x69\x6c\x65\x6e\x74\x20\x47\x75\x61\x72\x64\x69\x61\x6e",$/
>>>
>>>
>>
>>
>> --
>> Procuro emprego C.V:
>> http://danielmantovani.awardspace.com/
>>
>> print
>> "\x54\x68\x65\x20\x53\x69\x6c\x65\x6e\x74\x20\x47\x75\x61\x72\x64\x69\x61\x6e",$/
>>
>>
>> _______________________________________________
>> SaoPaulo-pm mailing list
>> SaoPaulo-pm em pm.org
>> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>>
>
>
>
> --
> André Garcia Carneiro
> Analista/Desenvolvedor Perl
>
>
> _______________________________________________
> SaoPaulo-pm mailing list
> SaoPaulo-pm em pm.org
> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>



-- 
Procuro emprego C.V:
http://danielmantovani.awardspace.com/

print
"\x54\x68\x65\x20\x53\x69\x6c\x65\x6e\x74\x20\x47\x75\x61\x72\x64\x69\x61\x6e",$/
-------------- Pr?xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20081212/5d8a2202/attachment-0001.html>


More information about the SaoPaulo-pm mailing list