Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

HTML-Template.r ?

 [1/7] from: peoyli:algonet:se at: 1-May-2001 13:47


Anyone working on a HTML::Template (Perl module) clone for REBOL ? Would be nice to be able to separate HTML code from script code sometimes (and then letting the REBOL CGI's concentrate on data processing) Info/Tutorial: http://www.perlmonth.com/features/template/template.html?issue=11 Source: http://sourceforge.net/projects/html-template/ /PeO

 [2/7] from: pa:russo:perd at: 1-May-2001 17:12


>Anyone working on a HTML::Template (Perl module) clone for REBOL ? >Would be nice to be able to separate HTML code from script code sometimes (and
<<quoted lines omitted: 4>>
>http://sourceforge.net/projects/html-template/ >/PeO
I don't know if you are referring to something like this exactly, but perhaps the following example could be useful to solve your problem. The logic is quite simple: 1. An HTML template with placeholders 2. A set of replacement rules 3. A cycle that replace the placeholders using the replacement rules Hope it helps. -- Paolo Russo #!/opt2/cyberurb/rebol/rebol -cs REBOL [ Title: "View a duello" Date: 07-jan-2001 Author: "Paolo Russo" Owner: "PERD s.r.l." Site: http://www.perd.com Email: [pa--russo--perd--com] File: %ilduello-view.r Project: 'duello Purpose: { Crea la maschera necessaria per votare un duello. } Comments: {} History: [ 04-mar-2001 "Modificato per visualizzare la schermata con i dati per votare" "Paolo Russo" 07-jan-2001 "Prima stesura" "Paolo Russo" ] Category: [CGI] Needs: [] Language: 'English ] ; ==== MODELLO DELLA PAGINA HTML html-template: { <HTML><HEAD> <TITLE>IL DUELLO: E ORA DECIDI TU!</TITLE> <LINK REL=STYLESHEET HREF="http://www.cyberurbs.com/duello/ilduello.css" TYPE="text/css"> </HEAD> <BODY BACKGROUND="http://www.ilduello.com/media/workspace.jpg"> <P class="titolopagina">___strillo___</P> <P>___descrizione___</P> <FORM ACTION="/cgi-bin/ilduello-vote.r" METHOD="GET"> <TABLE BORDER="0" CELLSPACING="12" CELLPADDING="1"> <TR ALIGN="left" VALIGN="top"> <TD COLSPAN="2">E ora decidi tu tra...</TD> </TR> <TR ALIGN="left" VALIGN="top"> <TD><INPUT NAME="duellante" TYPE="radio" VALUE="1" ><B>___duellante-1___</B></TD> <TD><INPUT NAME="duellante" TYPE="radio" VALUE="2"><B>___duellante-2___</B></TD> </TR> <TR ALIGN="left" VALIGN="top"> <TD>E-mail:</TD> <TD><INPUT NAME="email-address" TYPE="text" SIZE="40" MAXLENGTH="40"></TD> </TR> <TR ALIGN="left" VALIGN="top"> <TD>Password</TD> <TD><INPUT NAME="password" TYPE="password" SIZE="20" MAXLENGTH="20"></TD> </TR> <TR ALIGN="right" VALIGN="top"> <TD><INPUT NAME="duello" TYPE="hidden" VALUE="___codiceduello___"></TD> <TD><INPUT NAME="submit" TYPE="submit" VALUE=" vota! "></TD> </TR> </TABLE> </FORM> </BODY> </HTML> } ;==DEBUG TOOLS ;To be defined only during debugging. You MUST unset these words in the final version. ;debug-mode: 'on if not value? 'debug-mode [ print {Content-Type: text/html^/} ] ;Acquisizione dei dati di input either value? 'debug-mode [ ;deve ricevere una stringa del tipo -duellante1 vs. duellante2 [codiceduello]- ][ form-fields: make object! decode-cgi-query system/options/cgi/query-string ] ;Lettura dei dati either error? archivio-duelli: try [ load %ilduello-duelli.dat][ replacement-rules: [ ___strillo___ "Ooops..." ___descrizione___ "Archivio dei duelli momentaneamente non disponibile." ___duellante-1___ "" ___duellante-2___ "" ___codiceduello___ "" ] ][ either foreach duello archivio-duelli [ if duello/did = form-fields/did [ replacement-rules: compose [ ___strillo___ (duello/strillo) ___descrizione___ (duello/descrizione) ___duellante-1___ (duello/duellante/1) ___duellante-2___ (duello/duellante/2) ___codiceduello___ (duello/did) ] break/return true ] ][ ][ replacement-rules: [ ___strillo___ "Ooops..." ___descrizione___ "Il duello selezionato non &egrave; pi&ugrave; presente nell'archivio." ___duellante-1___ "" ___duellante-2___ "" ___codiceduello___ "" ] ] ] ; === Composizione della pagina HTML html-code: copy html-template foreach [ text-to-substitute replacement-text] replacement-rules [ replace/all html-code to-string text-to-substitute to-string replacement-text ] print html-code -- Paolo Russo [pa--russo--perd--com] _________________ PERD s.r.l. Virtual Technologies for Real Solutions http://www.perd.com

 [3/7] from: carl:rebol at: 2-May-2001 1:02


I've looked at it. Such a template system could be built in about a page or two of REBOL code. Would be very handy if anyone out there wants to code it... Here's a quick starter... template: load/markup template-file parse template [ some [to tag! set tag tag! (if find/match tag "tmpl" [do-tag tag]) ] ] or, as code: while [template: find template tag!] [ tag: first template template: next template if find/match tag "tmpl" [ tag: parse tag "=" switch first tag [ "tmpl_var" [...] "tmpl_loop' [...] ... ] ] ] Go for it. :) -Carl

 [4/7] from: peoyli:algonet:se at: 2-May-2001 10:39


> >Anyone working on a HTML::Template (Perl module) clone for REBOL ? > I don't know if you are referring to something like this exactly, but
<<quoted lines omitted: 5>>
> Hope it helps. > -- Paolo Russo
It is useful, but not as a HTML::Template replacement... The real strength of HTML::Template is loops <TMPL_LOOP NAME="a_loop">, which loops through a array of values, repeating the HTML code produced (useful for tables etc.) and conditional code <TMPL_IF.., <TMPL_ELSE.., <TMPL_UNLESS.., all of these can be nested within each other, and can be hidden in comments so HTML validators won't complain about unknown tags. <TMPL_VAR NAME="something"> is easy to implement using some replacement rules, but the rest requires some more parsing of the given template to find out what belongs to what.. /PeO

 [5/7] from: sbagnier:doubletrade at: 2-May-2001 10:57


It is basically the purpose of the Rebol Site Builder used by our association : http://d2set.free.fr/en/projects/site/RebolSiteBuilder/notice.html This tool should become free (GPL) and available on SourceForge. Anyone here interested to contribute ? Stephane Bagnier. "Carl Sassenrath" To: <[rebol-list--rebol--com]> <[carl--rebol--c] cc: om> Subject: [REBOL] Re: HTML-Template.r ? Sent by: rebol-bounce@ rebol.com 02/05/2001 10:02 Please respond to rebol-list I've looked at it. Such a template system could be built in about a page or two of REBOL code. Would be very handy if anyone out there wants to code it...

 [6/7] from: pa:russo:perd at: 2-May-2001 11:35


> > >Anyone working on a HTML::Template (Perl module) clone for REBOL ? >>
<<quoted lines omitted: 21>>
>to what.. >/PeO
I think it is possible an elegant solution through an approach based on recursion and self-similarity. I'm working on it and I hope to have the first results about mid-may. I'll post it here. -- Paolo Russo [pa--russo--perd--com] _________________ PERD s.r.l. Virtual Technologies for Real Solutions http://www.perd.com

 [7/7] from: arolls:bigpond:au at: 3-May-2001 4:02


This is a great site for learning French! I like the subject matter too :) Anton.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted