
###################################################################################
#
#   Embperl - Copyright (c) 1997-2001 Gerald Richter / ECOS
#
#   You may distribute under the terms of either the GNU General Public
#   License or the Artistic License, as specified in the Perl README file.
#
#   THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
#   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
#   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
#   $Id$
#
###################################################################################
 
package HTML::Embperl::Syntax::ASP ;

use HTML::Embperl::Syntax qw{:types} ;
use HTML::Embperl::Syntax::HTML ;

use strict ;
use vars qw{@ISA} ;

@ISA = qw(HTML::Embperl::Syntax::HTML) ;


###################################################################################
#
#   Methods
#
###################################################################################

# ---------------------------------------------------------------------------------
#
#   Create new Syntax Object
#
# ---------------------------------------------------------------------------------


sub new

    {
    my $class = shift ;

    my $self = HTML::Embperl::Syntax::HTML::new ($class) ;

    if (!$self -> {-aspInit})
        {
        $self -> {-aspInit} = 1 ;    
        Init ($self) ;
        }

    return $self ;
    }



###################################################################################
#
#   Definitions for ASP HTML tags
#
###################################################################################

sub Init

    {
    my ($self) = @_ ;


    $self -> AddToRoot ({
                        'ASP Code' => {
                            'text' => '<%',
                            'end'  => '%>',
                            'procinfo' => 
                                {
                                embperl => 
                                    { 
                                    perlcode    => '%$c%%#0%',
                                    removenode  => 3,
                                    mayjump     => 1,
                                    compilechilds => 0,
                                    },
                                },
                            }
                        }) ;

    $self -> AddToRoot ({
                        'ASP Output' => {
                            'text' => '<%=',
                            'end'  => '%>',
                            'procinfo' => {
                                embperl => { 
                                        perlcode => 
                                            [
                                            'if (!defined (_ep_rp(%$x%,scalar(%#~0:$col%)))) %#~-0:$row% { if ($col == 0) { _ep_dcp (%$t%,%^*htmltable%) ; last l%^*htmltable% ; } else { _ep_dcp (%$t%,%^*htmlrow%) ; last l%^*htmlrow% ; }}',
                                            'if (!defined (_ep_rp(%$x%,scalar(%#~0:$col%)))) { _ep_dcp (%$t%,%^*htmlrow%) ; last l%^*htmlrow% ; }',
                                            'if (!defined (_ep_rp(%$x%,scalar(%#~0:$row%)))) { _ep_dcp (%$t%,%^*htmltable%) ; last l%^*htmltable% ; }',
                                            '_ep_rp(%$x%,scalar(%#0%));', 
			                    ],
                                        removenode  => 4,
                                        mayjump => '%#~0:$col|$row|$cnt% %?*htmlrow% %?*htmltable%',
                                        compilechilds => 0,
                                        }
                                    }
                            }
                        }) ;
    }


###################################################################################
#
#   ASP Implementation
#
###################################################################################


1; 

__END__

=pod

=head1 NAME

ASP syntax module for Embperl 

=head1 SYNOPSIS

    [$syntax ASP $]

    <% $a = 1 ; %>
    <table>
        <% foreach (1..5) { %>
            <tr>
                <td><%= $_ %></td>
                <td><%= $a += 2 %></td>
            </tr>
        <% } %>
    </table>




=head1 DESCRIPTION

The module add the ASP syntax to Embperl. That mean when you select ASP as
syntax, Embperl understand the two following tags:

=over 4

=item <%   %>

Between <% and %> you can put any Perl code that should be executed.


=item <%=   %>

Between <%= and %> you can place a valid Perl expression and the result of
the expression is inserted instead of the <%= %> block.


=back

=head1 Author

Gerald Richter <richter@dev.ecos.de>

=head1 See Also

HTML::Embperl::Syntax

