Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]4557[/thread]

HTML::Template::Compiled (HTC) (Seite 9)

Leser: 31


<< |< 1 ... 6 7 8 9 10 11 12 ... 21 >| >> 210 Einträge, 21 Seiten
esskar
 2006-05-05 09:38
#40864 #40864
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
es ist kein guter Programmier-Stiel

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package Animal;

sub new {
return bless {}, shift;
}

sub to_string {
die "pure virtual\n";
}

1;

package Animal::Dog;

use base qw/Animal/;

sub to_string {
return "Hund";
}

1;

package Animal::Cat;

use base qw/Animal/;

sub to_string {
return "Katze";
}

1;

package Animal::Mouse;

use base qw/Animal/;

sub to_string {
return "Maus";
}

1;

package Animal::Farm;

sub new {
return bless {}, shift;
}

sub add {
my $self = shift;
if(@_ > 1) {
$self->add($_) foreach @_;
} else {
my $animal = shift;
die "Is not an animal!" unless $animal->isa('Animal');
$self->{animals} ||= [];
push @{ $self->{animals} }, $animal;
}
}

sub to_string {
my $self = shift;
$self->{animals} ||= [];
return join ' ', map { $_->to_string } @{ $self->{animals} };
}

1;

# hier beginnt das script

#!/usr/bin/perl

use strict;

my $farm = Animal::Farm->new;
$farm->add(Animal::Dog->new);
$farm->add(Animal::Cat->new, Animal::Mouse->new);

my $template = HTML::Template::Compiled->new (
filename => $tmpl_file,
path => $mein_pfad,
use_query => 1
);

$template->param( farm => $farm );


im Template

Code: (dl )
<%= farm.to_string %>


HTH

PS: ungetestet
MartinR
 2006-05-05 10:19
#40865 #40865
User since
2004-06-17
305 Artikel
BenutzerIn
[default_avatar]
Danke esskar,

aber mit OOP stehe ich leider immer noch auf Kriegsfuss. Ich verstehe zwar bei so einfachen Codes die Funktion aber leider nicht den Sinn. Werden die Scripts dann komplizierter sehe ich oft einen Sinn, verstehe aber die Funktion nicht mehr ...

Also bin ich dann meist schon froh, wenn es hinterher funktioniert. Und das ist auch der Grund warum ich Perl so gerne mag - irgendwie geht es eben immer.\n\n

<!--EDIT|MartinR|1146810069-->
pq
 2006-06-02 01:56
#40866 #40866
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
Code: (dl )
1
2
3
4
5
6
0.64 Thu Jun  1 23:54:32 CEST 2006
- bug with undefined filename and INCLUDE_VAR
- New Feature: alias
- Change: TMPL_IF DEFINED deprecated
- Change: TMPL_INCLUDE VAR from deprecated to forbidden
- New Feature: Define your own tagstyles
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
esskar
 2006-06-02 04:33
#40867 #40867
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
pq++
renee
 2006-06-02 08:58
#40868 #40868
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Quote
Code: (dl )
1
2
0.64 Thu Jun  1 23:54:32 CEST 2006
- bug with undefined filename and INCLUDE_VAR


@pq: Das ist aber nett, dass Du sogar in das Change-File schreibst, welche Bugs Du einbaust :p SCNR
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
pq
 2006-06-02 12:19
#40869 #40869
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
[quote=renee,02.06.2006, 06:58]
Quote
Code: (dl )
1
2
0.64 Thu Jun  1 23:54:32 CEST 2006
- bug with undefined filename and INCLUDE_VAR


@pq: Das ist aber nett, dass Du sogar in das Change-File schreibst, welche Bugs Du einbaust :p  SCNR[/quote]
hab ich jetzt geändert =)

muss noch eine version hochladen, da ein fehler im pod alles zerschossen hat.
Code: (dl )
1
2
3
4
5
6
7
8
9
0.65 Fri Jun  2 10:10:06 CEST 2006
- Bug Fix: Documentation error broke pod

0.64 Thu Jun  1 23:54:32 CEST 2006
- Bug Fix: undefined filename and INCLUDE_VAR
- New Feature: alias
- Change: TMPL_IF DEFINED deprecated
- Change: TMPL_INCLUDE VAR from deprecated to forbidden
- New Feature: Define your own tagstyles
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
esskar
 2006-06-02 14:30
#40870 #40870
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=pq,02.06.2006, 10:19]muss noch eine version hochladen, da ein fehler im pod alles zerschossen hat.[/quote]
ist mir auch aufgefallen; hatte ich auch schon mal bei einem meiner module; sah mir damals aber nach willkür aus.
woran lag es bei dir?
pq
 2006-06-02 19:16
#40871 #40871
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
im HTML/Template/Compiled/Parser.pm stand

Code: (dl )
1
2
=head1 NAME
HTML::Template::Compiled - Parser Module for HTML::Template::Compiled


siehe http://search.cpan.org/diff?fr....rser.pm (übrigens oft ganz praktisch, dieses CPAN-diff)\n\n

<!--EDIT|pq|1149261501-->
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
GwenDragon
 2006-06-02 19:33
#40872 #40872
User since
2005-01-17
14848 Artikel
Admin1
[Homepage]
user image
@pq
So eine vergessene Leerzeile beim pod schleicht sich schon mal beim Erstellen von Dokumentation ein.

Übrigens,
Danke sehr für die neue Version! :)
pq
 2006-06-02 21:31
#40873 #40873
User since
2003-08-04
12209 Artikel
Admin1
[Homepage]
user image
nein, sorry, die leerzeile war da. das hätte Test::Pod hoffentlich gemerkt, wenn nicht. (edit: hmpf, hätte es nicht)
es war der name des moduls. siehst du auch im diff.

hier: http://search.cpan.org/~tinita/HTML-Template-Compiled-0.64/ siehst du, was CPAN draus gemacht hat (bei klick auf HTML::Template::Compiled kriegst du die doku du HTC::Parser)\n\n

<!--EDIT|pq|1149269652-->
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wiki:Wie frage ich & perlintro Wiki:brian's Leitfaden für jedes Perl-Problem
<< |< 1 ... 6 7 8 9 10 11 12 ... 21 >| >> 210 Einträge, 21 Seiten



View all threads created 2005-06-26 15:48.