in reply to Re^2: Too difficult for me...
in thread Too difficult for me...
I can only recommend to you to write a compiler that takes your input language and outputs (for example) Perl:
... could become<div id="comments"> <table> (sql mode="mask") <query> SELECT * FROM comments LIMIT (qd)limit(/qd); </query> <mask> <tr> <td><d>comment</d></td> <td>[link action="showuser" userid="<d>userid</d>" ]<d>username</d>[/link]</td> <td><d>timestamp</d></td> </tr> </mask> (/sql) </table> </div>
my $output; $output .= <<HTML; <div id="comments"> <table> HTML my $limit = get_qd('limit'); # whatever "qd" is supposed to be my $results = fetch_sql( mode => "mask", query => <<SQL); SELECT * FROM comments LIMIT (qd)limit(/qd); SQL for my $row (@$results) { $output .= <<HTML; <mask> <tr> <td> HTML $output .= $row->{comment}; $output .= <<HTML; </td> <td> HTML $output .= link( action => 'showuser', userid => $row->{userid}, text +=> <<HTML ); $row->{username} HTML $output .= <<HTML; </td> <td> HTML $output .= $row->{timestamp}; $output .= <<HTML; </td> </tr> </mask> HTML }; # (/sql) $output .= <<HTML </table> </div> HTML
This is basically the same technique that Template uses. The remaining infrastructure of including parts of pages from other code reminds me of HTML::Mason. I think you could learn lots from looking at the respective implementations. The Everything Engine (which this site runs on) is also fairly similar, except that it doesn't try to encode database queries as HTML - it leaves plain Perl for that. Subroutine calls can be encoded as special tags, but I'm not sure that this is an overall good idea.
Note that I'm no friend of large frameworks, because they usually work for nobody other than the author(s).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Too difficult for me...
by simonodell (Acolyte) on Jun 19, 2011 at 12:05 UTC | |
by Corion (Patriarch) on Jun 19, 2011 at 12:16 UTC | |
by simonodell (Acolyte) on Jun 19, 2011 at 12:39 UTC | |
by Corion (Patriarch) on Jun 19, 2011 at 12:55 UTC | |
by simonodell (Acolyte) on Jun 19, 2011 at 12:20 UTC |