½ÃÀÛÆäÀÌÁö·Î Áñ°Üã±âÃß°¡
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ l Ã⼮üũ l ¸¶ÀÌÆäÀÌÁö l CGIMALL
ÀÚ·á½Ç »çÀÌÆ®µî·Ï ·©Å·100 ÇÁ·Î±×·¥¸®ºä °ü¸®ÀÚÃßõÀÚ·á Ãʺ¸°¡À̵å
Ä¿¹Â´ÏƼ
Àüü ÆîÃ帱â
Äü¸Þ´º¸µÅ© jquery , CSS , PHP , Javascript , ¹«·áÆùÆ® , ASP
»ó¼¼°Ë»ö
Ȩ > Ä¿¹Â´ÏƼ > Áú¹®°ú´äº¯ »ó¼¼º¸±â
Ä¿¹Â´ÏƼ ±¸Àα¸Á÷
»çÀÌÆ®µî·Ï
Ŭ¶ó¿ìµåű×
Javascript
PHP
ASP
CSS
html
mysql
jquery
image
API
Mobile
¸Þ´º
slide
°Ô½ÃÆÇ
ÇöÀçÁ¢¼ÓÀÚ ¸í »õ·Î°íħ
°Ô½ÃÆÇŸÀÌƲ Áú¹®°ú´äº¯ / »ó¼¼º¸±â
Æ®À§ÅÍ·Î º¸³»±â
Ãßõ¼ö 96 | Á¶È¸¼ö 951 | µî·ÏÀÏ 1999-06-20 04:44:37

´Ð³×ÀÓ

HappyCGI

À̸ÞÀÏ

hero@happycgi.com

Á¦¸ñ

[Ç÷¯±×ÀÎ] ¸µ½º 2.0 ¿ÜºÎ ÆÄÀÏ ´ç°Ü¾²±â
³»¿ë
¸µ½º ¿ÜºÎ ÆÄÀÏ ´ç°Ü ¾²±â¿¡ °üÇÑ ¼³¸íÀÔ´Ï´Ù.
Áï º¸Åë ÅÛÇø®Æ®¸¦ ¸¸µé¶§ html ¸¸ »ç¿ëÇÏÁÒ.
±× ÅÛÇø®Æ®ÀÇ html ³»¿¡ ¶Ç ´Ù¸¥ ÆÄÀÏÀ» ´ç°Ü ¾²´Â ¹ýÀÔ´Ï´Ù.
¸¸¾à header.txt ¿Í footer.txt¸¦ ¸¸µé¾î ³õ°í ¸¹Àº ÅÛÇø®Æ® ÆÄÀÏ¿¡
»ç¿ëÇÑ´Ù¸é ¿ì~ ¹«Áö ÆíÇÏ°ÚÂÇ ^^;
¿ì¼± template.pm ÆÄÀÏÀ» ¿­¾îº¾´Ï´Ù.
´ÙÀ½ sub parse ·çƾÀ» ã½À´Ï´Ù.
¿ä ·çƾÀ» ±×³É ´Ù Áö¿ì°í ¾Æ·¡¸¦ º¹»çÇؼ­ ºÙÀ̼¼¿ä.

sub parse {
# ---------------------------------------------------------------
# Parses a template.
#
    my $self    = shift;
    my $template = shift;
    my $begin    = $self->{
begin
} &pip;&pip; quotemeta(
<%
);
    my $end      = $self->{
begin
} &pip;&pip; quotemeta(
%>
);
    exists $self->{
templates
}{$template} or ($self->load_template($template) or return undef);
    exists $self->{
vars
} or (&error (
NONAMESPACE
) and return undef);
    $self->{
parsed
}{$template} =

;
    my $temp = $self->{
templates
}{$template};
# Parse includes, do this first so that the includes can include
# template tags.
    $temp =~ s#$begins*includes*(. ?)s*$end#
            if (exists $self->{
inc
}{$1}) { $self->{
inc
}{$1}; }
            else {
                if (open (INC, "${$self}{
ROOT
}/$1")) {
                    $self->{
inc
}{$1} = join ("", );
                    close INC;
                    $self->{
inc
}{$1};
                }
                else {
                    "Can
t find file: ${$self}{
ROOT
}/$1";
                }
            }
        #goe;
# Now go line by line and strip out the unwanted stuff looking for
# if and ifnot tags.
    my @lines = split /
/, $temp;
    $temp    =

; my @go = (1,1); my $depth = 1; my $line =

;
    LINE: foreach $line (@lines) {
# Init the previous, variable and more strings.
        my ($prev, $var, $neg, $more, $orig) = (

,

,

,

,

);
# Check for if tags.
        $line =~ s/((.*?)$begins*if(not)?s (. ?)s*$end(.*))/
                    ($orig, $prev, $neg, $var, $more) = ($1, $2, $3, $4, $5);
# We
ve found an if tag, let
s set the depth to see whether we are in print mode or not.
                    if ($prev !~ m,$begins*(. )s*$end,og) {
                        $go[$depth] and ($temp .= $prev);
                        if ($neg) {
                            ($self->{
vars
}{$var}) ?
                                ($go[  $depth] = 0) : ($go[  $depth] = $go[$depth]) and "";
                        }
                        else {
                            ($self->{
vars
}{$var}) ?
                                ($go[  $depth] = $go[$depth]) : ($go[  $depth] = 0) and "";
                        }
                    }
                    else {
# Oops, there was an endif tag we missed, set the original line back and keep going.
                        $more =

;    $orig;
                    }
                /oe;
        if ($more) { $line = $more; redo LINE; }
# Check for endif tags.
        $line =~ s/(.*?)$begins*endifs*$end(.*)/
                    ($prev, $more) = ($1, $2);
                    $go[$depth] and ($temp .= $prev);
                    ($go[$depth--] = 1) and "";
                /oe;
        if ($more) { $line = $more; redo LINE; }
# Add the content..
        $go[$depth] and ($temp .= "$line
");
    }
# Replace the special variables, we allow code ref mapping.
    $temp =~ s/$begins*(. ?)s*$end/
            if (exists $self->{
vars
}{$1}) {
                ref ($self->{
vars
}{$1}) eq
CODE
?
                    &{$self->{
vars
}{$1}} : $self->{
vars
}{$1};
            }
            else { "Unkown Tag: $1"; }
        /goe;
    $self->{
parsed
}{$template} = $temp;
    return $self->{
parsed
}{$template};
}

´ÙÀ½ º¸Åë cgi-bin/admin/templates µð·ºÅ丮·Î °¡¸é ¹«Áö ¸¹Àº html
ÅÛÇø®Æ®°¡ ÀÖÁÒ?
±×³ðÁß Çѳð home.htmlÀ» ¿­¾ú´Ù°í °¡Á¤ÇÕ´Ï´Ù.
(Âü ±×Àü¿¡ ÀÌ µð·ºÅ丮¿¡ header.txt footer.txtÆÄÀÏÀ» ¸¸µé¾î ³Ö¾ú´Ù°í
°¡Á¤ÇÕ´Ï´Ù.)
°Å±â¿¡¼­ ¾Æ·¡¿Í °°Àº ű׸¦ ³Ö¾îº¾´Ï´Ù.
<%include header.txt%>
±×·¯¸é header.txt ÆÄÀÏÀÌ ÂüÁ¶°¡ µÇ¾î header.txt ÆÄÀÏÀ» Àаí home.html ÆÄÀÏÀ»
¶Ç Àо ÆäÀÌÁö¸¦ »ý¼ºÇس»ÁÒ.
footer.txt µµ ¸¶Âù°¡Áö ÀÔ´Ï´Ù.
±Ùµ¥ ¹¹°¡ ÁÁ³Ä±¸¿ä?
¿õ~
¼ö½Ê°³ÀÇ htmlÀº ´ç¿¬È÷ °°Àº ÇüÅ·ΠÀ¯Áö µÇ¾î Áú°Ì´Ï´Ù.
ƯÈ÷ »ó´Ü°ú ÇÏ´Ü ºÎºÐÀº °°Àº Å×ÀÌºí¿¡ °°Àº À̹ÌÁö ÅؽºÆ®°¡ ¸¹ÀÌ ¾²ÀÌÁÒ.
¿ä³ðÀ» »ç¿ëÇÏ¸é ¹Ýº¹ ÀÛ¾÷À» ÇÇÇÒ¼ö°¡ ÀÖÁÒ.
±× ¸¹Àº html¿¡ header.txt¿Í footer.txt ÆÄÀÏÀ» ¸¸µé¾î ³Ö±â¸¸ Çϸé
°¢°¢ÀÇ htmlÀº ³»¿ë¸¸ ½ï µé¾î°¡¸é ȨÆäÀÌÁö ÀÛ¾÷ÀÌ ³¡~ À̳׿ä.
±×·³ Çѹø ½áº¸¼¼¿ä.

Ãßõ½ºÅ©·¦¼Ò½ºº¸±â ¸ñ·Ï
ÀÌÀü°Ô½Ã±Û [Áú¹®] ¸µ½º2.0 °Ë»ö½Ã °á°úÃâ·Â¿¡ À־ÀÇ ¹®Á¦?? 1999-06-20 04:28:22
´ÙÀ½°Ô½Ã±Û [Ç÷¯±×ÀÎ] ¸µ½º 2.0 °ü¸®ÀÚ ¸ðµå º¸±âÁÁ°Ô ¸¸µé¾î Áֳ׿ä. 1999-06-20 08:07:29