Hi Justin,
> The deal here is that I've written some functions into these Mason
> components that I don't want to have to write over. Its not just
> things
I think you've got just the right ide. Refactor piece by piece and
you'll be able to reuse your tried and true code from many places. On
that note, my first suggestion would be to write some tests if you
don't already have them.
> <& 'some/comp.mas', foo => $foo, bar => "baz", %ARGS %>
What you change this too depends on what you do in comp.mas - if you
generate HTML in there you probably won't change this call at all.
In general, component calls that return HTML will stay the same,
while component calls that do not return HTML will become calls into
modules.
If comp.mas just calculates something, the above call might change to:
% JCook::Some::comp( foo => $foo, bar => "baz", %ARGS );
> What would I change it to, but more importantly in 'some/comp.mas':
>
> <%args>
> $foo
> $bar
> </%args>
>
> ...some code...
> if ($ARGS{'who'} eq "you") {
> ...
> }
> ...
Ideally, your components will make a call to a module to get some
data, then use Mason to display it:
<%init>
my @results = JCook::Some::comp( %ARGS );
<%/init>
<ul>
% for my $result ( @results ) {
<li><% $result %>
% }
</ul>
And now you can call JCook::Some::comp from lots of places!
HTH,
Aaron
> Justin
>
>>> From: J Cook <[EMAIL PROTECTED]>
>>> To: [email protected]
>>> Date: Wed, 14 Jun 2006 10:31:51 -0400
>>> Subject: [Mason] Converting .mas component to perl module - Any
>>> Suggestions?
>>>
>>> I made the mistake of using Mason components where I should have
>>> made
>>> Perl modules. On one hand its nice because I don't have to restart
>>> apache every time I modify a component file, but I guess that I am
>>> taking a performance hit for doing things this way. I used Mason
>>> like
>>> someone would use PHP you could say(and my Perl is like Mason-
>>> flavored
>>> slang).
>>>
>>> But now I'm looking at making some applications in Catalyst, and
>>> I want
>>> to make these Mason components Perl modules so I can use them in
>>> these
>>> new apps.
>>>
>>> So the question is - does anyone have any suggestions on the best
>>> way to
>>> convert a .mas component to a Perl module? Take into
>>> consideration that
>>> I'm passing arguments around using <%args> as well as %ARGS in
>>> many of
>>> these components. Anyone?
>>>
>>> TIA
>>>
>>> Justin
>>>
>>>
>>>
>>> _______________________________________________
>>> Mason-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/mason-users
>>>
>>>
>>>
>>
>>
>>
>
>
>
> _______________________________________________
> Mason-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mason-users
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users