HTML-XHTML-DVSM

 view release on metacpan or  search on metacpan

DVSM.pm  view on Meta::CPAN

        my %copymarkup = %{$self->{Markup}};        
        ${$self->{MarkupCache}}{$cachename} = \%copymarkup;
        my $copySubs = $sbSubs;
        ${$self->{SubsCache}}{$cachename} = \$copySubs;
    }
    return 0;
}


sub sbInit() {
    my $self = shift;
    my @sbInstructions = ();
    my %sbMarkup = ();
    my @sbTagparents = ();
    my @sbInstrstack = (\@sbInstructions);
    $self->{Instructions} = \@sbInstructions;
    $self->{Markup} = \%sbMarkup;
    $self->{Tagparents} = \@sbTagparents;
    $self->{Instrstack} = \@sbInstrstack;
    $self->{LastError} = "";
    $self->{CurrentTag} = 0;
}

sub sbGetPath {
    my $class = shift;
    my $path = shift;
    $path =~ s#\\#/#g;
    if ( $path =~ m#(.+)/([^/]+$)# ) {
        $path = $1;
        my $file = $2;
        return ( $path, $file ) if ( wantarray() );
        return $path;
    }
    else {
        return ( "", $path ) if ( wantarray() );
        return "";
    }
}

sub sbBasename {
    my $class = shift;
    my $pathname = shift;
    my ( $path, $filename ) = sbGetPath( $pathname );
    return $path;
}

sub sbFilename {
    my $class = shift;
    my $pathname = shift;
    my ( $path, $filename ) = sbGetPath( $pathname );
    return $filename;
}

return 1;


__END__

=head1 NAME

HTML::XHTML::DVSM - Dynamic Visual Software Modelling, XML/XHTML template system that does not screw up your templates. V1.2

=head1 SYNOPSIS

=over 4

=item The HTML - getstarted.html 

Illustrates all but one of the the DVSM commands that can be 
embedded into xml or xhtml markup, and the missing one is explained below.   
All markup must be xhtml not html.

    <html>
    <head>
    <title>Getting Started with HTML::XHTML::DVSM</title>
    </head>
    <body>
    <h1>Getting Started with HTML::XHTML::DVSM</h1>
    This html markup illustrated the script commands available in HTML::XHTML::DVSM<br/>
    run printheader has output the header<br/>
    <h2>RUN</h2>
    run dorun will output "doRun called 1 times"<Br/>
    <span id="sid">hello world</span><br/>
    run dorun will output "doRun called 2 times"<br/>
    <span id="sid2">hello world</span>
    <!--DVSM
    run "printHeader"
    run "doRun()" where id = "sid"
    run "doRun()" where id = "sid2"
    -->
    <!--DSUBS
    sub printHeader { print "Content-type: text/html\n\n"; }
    my $count = 0;
    sub doRun {
        ++$count;
        print "doRun called $count times<br/>\n";
    }
    -->
    <h2>SET</h2>
    textnode is set from hello world to hello sid<br/>
    <span id="set">hello world</span><br/>
    value of input is set to "set by set"<br/>
    <input type="text" value="" name="set2">
    <!--DVSM
    set textnode to "sayHello()" where id = "set"
    set value to "return 'set by set';" where name = "set2"
    -->
    <!--DSUBS
    sub sayHello {
        return "hello sid";
    }
    -->
    <h2>TOGGLE</h2>
    Current value set to Option 2 by TOGGLE command<br/>
    <select name="myselect">
    <option value="1" select="myselect">Option 1</option>
    <option value="2" select="myselect">Option 2</option>
    <option value="3" select="myselect">Otpion 3</option>
    </select><br/>
    <!--DVSM
    toggle selected to "doToggle()" where select = "myselect"

DVSM.pm  view on Meta::CPAN

    end while 

Attaches itself to tags where attribute is equal to "value".  
It keeps repeating the tag while boolean_function() returns true.  
For each copy of the tag, it runs child instructions to the child tags.

Example:

    <html><body>
    <table>
    <tr><th>Customer Number</th><th>Customer Name</th></tr>
    <tbody>
    <tr name="customers"><td name="custid">12345</td><td name="custname">Mr Bloggs</td></tr>
    <tr name="deleteme"><td>23456</td><td>Mrs Soap</td></tr>
    <tr name="deleteme"><td>67890</td><td>Mr A N Other</td></tr>
    </tbody>
    </table>
    </body></html>
    <!--DVSM
    delete where name = "deleteme"
    while "moreCustomers()" where name = "customers"
       set textnode to "getCustid()" where name = "custid"
       set textnode to "getCustname()" where name = "custname"
    end while
    -->
    <!--DSUBS
    my %db = ( 148842 => "Mr J Smith", 848488 => "Ms S Jones", 484848 => "Mrs P Cook" );
    my $cursor = -1;
    sub moreCustomers {
        $cursor++;
        my @keys = keys( %db );
        return ( $cursor < @keys );
    }
    sub getCustid {
        my @keys = sort keys( %db );
        return $keys[$cursor];
    }
    sub getCustname {
        return $db{getCustid()};
    }
    --> 

Result:

    <html><body>
    <table>
    <tr><th>Customer Number</th><th>Customer Name</th></tr>
    <tbody>
    <tr name="customers"><td name="custid">148842</td><td name="custname">Mr J Smith</td></tr>
    <tr name="customers"><td name="custid">484848</td><td name="custname">Mrs P Cook</td></tr>
    <tr name="customers"><td name="custid">848488</td><td name="custname">Ms S Jones</td></tr>
    </tbody>
    </table>
    </body></html>

=back

=head1 README

C<HTML::XHTML::DVSM> A perl module that uses a simple scripting language embedded within
XML/XHTML markup to change the markup by adding, removing and
changing tags and attributes. The obvious application is for
generating dynamic web sites. But other applications would be
generating XUL gui screens (using XULs such as thinlet), or B2B XML
documents.

The unique thing about DVSM is it does NOT corrupt your original XML/XHTML. After XHTML is 
developed to run dynamically in your website you can still load the template xhtml into your
dreamweaver or other html tool and it will look exactly the same as it did before.  You can
do a storyboard of your whole website and the story board will be preserved even when it is
used as a template for your dynamic, live website.

=head1 PREREQUISITES

Other than for the use of C<strict> there are actually no dependancies in HTML::XHTML::DVSM.
It uses simple regular expressions to parse script elements and xml/xhtml.  In future
should there be demand, it would probably be amended to allow the use of a proper XML
parser and perhaps a robust mini-language compiler/interpreter.  But the aim is to
allow HTML::XHTML::DVSM to be used with the most primitive web hoster.  If there is perl, HTML::XHTML::DVSM
will run.

IO::String is required for the unit tests.  It is not needed by HTML::XHTML::DVSM itself.

=head1 OSNAMES

any

=head1 SCRIPT CATEGORIES



=head1 AUTHORS

Copyright © 2007-2010 Stuart Butler (perldev@yahoo.co.uk) and Grant Holman (grant@collegeroad.eclipse.co.uk).

=cut



( run in 1.772 second using v1.01-cache-2.11-cpan-119454b85a5 )