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

[REBOL] Rebol Server Pages

From: al::bri::xtra::co::nz at: 7-Oct-2002 16:59

Here's %Test.rsp, a example Rebol Server Pages file: <html> <head><title>Test</title></head> <body> <h1>Test</h1> <% random/seed now either random true [ %> Have a <b>nice</b> day! <% ] [ %> Have a <b>lousy</b> day! <% ] %> <br/> The date and time now is: <% now %> </body> </html> Note that "<%" and "%>" surround sections of Rebol script. It could be created by a HTML editor, I hope! :) I used my ML dialect to generate most of it, then edited by hand. Here's the RSP function: RSP: function [Text [string!]] [Open Close RSP Script String] [ Open: "<%" Close: "%>" RSP: make string! length? Text parse/all Text [ any [ end break | Open copy Script to Close Close (append RSP Script) | copy String [to Open | to end] (append RSP mold String) ] ] form replace/all reduce load RSP unset! "" ] Note that 'RSP is based on Rebol's 'build-markup. Here's the test script: write %Test.html RSP read %Test.rsp browse %Test.html And here's the generated HTML (I viewed the source and cut and pasted to this email: <html> <head><title>Test</title></head> <body> <h1>Test</h1> Have a <b>nice</b> day! <br/> The date and time now is: 7-Oct-2002/16:46:25+13:00 </body> </html> Note that the browser discards the extra spaces and line breaks shown here. Andrew Martin ICQ: 26227169