perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gerald Richter" <rich...@ecos.de>
Subject RE: Subroutine Inheritance
Date Wed, 25 May 2005 04:04:06 GMT
> 
> I want to set up a method accessed from the request object 
> that will allow me the option to create a page title based on 
> the path to the page.  What I was thinking was:
> 

In your page you say

[! Execute ({isa => 'title.epl'}) !]

In your title.epl you say

[! Execute ({isa => '../title.epl'}) !]

That should do the the trick of setting up @ISA

BTW. I would use 

<title>[+ $req->title() +]</title>

And then return the title string instead of print OUT

Gerald



> /base.epl
> [! sub title { print OUT "Company"; } !]
> [- $req = shift -]
> <title>[- $req->title() -]</title>
> 
> /title.epl
> [! sub title { print OUT " "; } !]
> 
> /foo/title.epl
> [! sub title { 
>         my ($self) = @_;
>         $self->SUPER::title();
>         print OUT " : Products";
> } !]
> 
> /foo/index.html
> [! sub title { 
>         my ($self) = @_;
>         $self->SUPER::title();
>         print OUT " : Widget";
> } !]
> 
> Then, visiting /foo/index.html would give you a page with the 
> title "Company : Products : Widget".  As I went deeper in the 
> directory tree, I could have more title.epl files, and thus a 
> longer title.  For instance, if I add:
> 
> /foo/bar/title.epl
> [! sub title { 
>         my ($self) = @_;
>         $self->SUPER::title();
>         print OUT " : Downloads";
> } !]
> 
> /foo/bar/index.html
> [! sub title { 
>         my ($self) = @_;
>         $self->SUPER::title();
>         print OUT " : Widget";
> } !
> 
> Then the page /foo/bar/index.html would have the title 
> "Company : Products : Downloads : Widget".  I can get the 
> inheritance between the /base.epl and whatever index.html 
> page I have working fine.  That's no problem.  The problem is 
> getting the title.epl involved.  I want to use normal 
> Embperl::Object file inheritance for title.epl files, but 
> want it to be inbetween the base.epl and index.html in the heirarchy. 
> 
> Is there a clever way to play with @ISA to accomplish this?  
> Or perhaps someone has a better idea for building titles?
> 
> 
> -Derrick
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message