Re: [Catalyst] CGI.pm and Catalyst?

2008-03-07 Thread Kieren Diment


On 7 Mar 2008, at 19:23, Martin Ellison wrote:

Is there anything attached to Catalyst similar to the CGI.pm  
module? That

is, creating the HTML by a series of procedure calls rather than by
instantiating a template?

Or is there some way to link up the existing CGI module?
$c-response-body(ul(li(q{hello}),
li(q{world} ?

Or is it not a good idea?

I couldn't find anything from a search, so excuse me please if this  
has been

covered before.



Don't use cgi.pm with catalyst, it's a bad idea which has bitten me  
in the arse for reasons I forget.  Perhaps you want html::tiny,  
although I'd really recommend that you use a proper template engine,  
otherwise your code will grow into a horrible monster before you know  
it.


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] CGI.pm and Catalyst?

2008-03-07 Thread Alex Povolotsky

Martin Ellison wrote:
Is there anything attached to Catalyst similar to the CGI.pm module? 
That is, creating the HTML by a series of procedure calls rather than 
by instantiating a template?


Or is there some way to link up the existing CGI module? 
$c-response-body(ul(li(q{hello}), li(q{world} ?


Or is it not a good idea?

I couldn't find anything from a search, so excuse me please if this 
has been covered before.


Creating HTML inside the code is the best way to make unreadable, 
unmaintainable program with mysterious errors.


Alex.

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] CGI.pm and Catalyst?

2008-03-07 Thread Cosimo Streppone

Alex Povolotsky wrote:

Martin Ellison wrote:
Is there anything attached to Catalyst similar to the CGI.pm module? 
That is, creating the HTML by a series of procedure calls rather than 
by instantiating a template?


Creating HTML inside the code is the best way to make unreadable, 
unmaintainable program with mysterious errors.


Also, Kieren Diment wrote:

 I'd really recommend that you use a proper template engine,
 otherwise your code will grow into a horrible monster before you know it.

It seems to me that these are generalizations. They are often true, but
it is indeed possible to create html inside your code, while keeping
a clean and oo approach.

For example, I designed and maintained for years a web framework where
we allowed something like:

   my $table = html::styledtable-new(skin='whatever');
   my $chart = html::chart-(type='pie3d', data=[EMAIL PROTECTED]);
   my $tree  = html::treeview-new(plugin='filesystem', subtree='/mypath');
   my $doc   = html::document-new(splashscreen=1);

   $table-add_row('this', 'that');
   $table-add_row($chart);
   $table-set_cell_opt(1, 0, colspan=2);

   $doc-body-add($table);
   $doc-body-add($tree);

We had many kind of html widgets, from simple ones, like 'table',
to complex ones, like 'treeview' or 'multiselect', or charts.

You can still separate (almost) clearly your presentation from your 
application logic, and your code is highly maintainable,

at least IMO.

You can also evolve (or change completely) your application presentation, or 
even changing the underlying layer to use pre-made templates, without

touching a single line of application code.

--
Cosimo


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] CGI.pm and Catalyst?

2008-03-07 Thread Ash Berlin

On 7 Mar 2008, at 09:03, Alex Povolotsky wrote:


Martin Ellison wrote:
Is there anything attached to Catalyst similar to the CGI.pm  
module? That is, creating the HTML by a series of procedure calls  
rather than by instantiating a template?


Or is there some way to link up the existing CGI module? $c- 
response-body(ul(li(q{hello}), li(q{world} ?


Or is it not a good idea?

I couldn't find anything from a search, so excuse me please if this  
has been covered before.


Creating HTML inside the code is the best way to make unreadable,  
unmaintainable program with mysterious errors.


Alex.


There's always Template::Declare[0] which lets you do

template simple = sub { html { head {} body { p {'Hello, world wide  
web!'} } } };
And keep the html in a sensible place (i.e. not in your controllers).  
Never used it but i know Jon Rockway has so perhaps he can comment on  
how useful it actually is.


-ash
[0]: 
http://search.cpan.org/~sartak/Template-Declare-0.28/lib/Template/Declare.pm___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] CGI.pm and Catalyst?

2008-03-07 Thread Allen S. Rout

 On Fri, 07 Mar 2008 10:24:45 +0100, Cosimo Streppone [EMAIL PROTECTED] 
 said:

 For example, I designed and maintained for years a web framework where
 we allowed something like:

 $table-add_row('this', 'that');
 $table-add_row($chart);
 $table-set_cell_opt(1, 0, colspan=2);

 $doc-body-add($table);
 $doc-body-add($tree);

 We had many kind of html widgets, from simple ones, like 'table',
 to complex ones, like 'treeview' or 'multiselect', or charts.


Yes.  I did that too.  It was keen in 1997, and the reason I was using
those idioms was because e.g. HTML::Mason didn't exist then.  (*koff*
and in 1998 I was still certain enough of my own invincibility I
wouldn't look around for the help) and now I have a pain in the butt.

 You can still separate (almost) clearly your presentation from your
 application logic, and your code is highly maintainable, at least
 IMO.

It's only maintainable for you.  And once you've actually -maintained-
it for 7 years, you'll find yourself hesitant to assert that much.
Code senescence is real.

Seriously.  Every iota of infrastructure you can punt to some larger
community's set of rules and conventions is a win.  


- Allen S. Rout

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/