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

[REBOL] Re: Stupid Parse Tricks

From: gjones05:mail:orion at: 6-Jun-2001 15:44

From: "John Schuhr"
> Greetings list, > Since playing with the eRebol utility by > Maarten Koopmans, I've become > interested in writing a full-featured markup > language similar to Allaire's (Macromedia) > Cold Fusion. Theoretically (with the right > dialect), it would be able to process CF > templates, but would be much more extensible. > Unfortunately, the nuances of the 'parse dialect > are still a bit mysterious to me. I'm still hunting > for lots of documentation and examples. But > one of the fundamental things I am curious to > know up-front, is can it be done with one rule > or will I need to create lots of little rules and > loop through the template, matching rules as > I go? A template might look like the following:
> Just look'n for insight :) Thanks.
Hi, John. Just one as far as I can tell. Here is a template that you can use. Watch for wrapping lines. Happy ereboling. --Scott Jones ;======================== REBOL [comment: "prelim erebol extender"] data: { <html><body> Login Report<br> <!--- logins in with mysql:// for example ---> <!--- and stores the result set for future use ---> <rebquery datasource="" dbname="logindb" name="qryLogins"> select * from tblLogin </rebquery> <table> <tr> <td>User Name</td> <td>Time Logged In</td> </tr> <rebout query="qryLogins"> <tr> <td>#LoginName#</td> <td>#LoginTime#</td> </tr> </rebout> </table> <br> The current time is: <rebscript> print now/time </rebscript> <br> The current date is: <rebout> #now/date# </rebout> </body></html> } reb-querys: copy [] rebout-vars: copy [] reb-scripts: copy [] rule: [ any [ thru "<rebquery" copy reb-query to </rebquery> (temp: copy parse/all reb-query ">" foreach p parse temp/1 none [append reb-querys p] temp: copy rejoin [{sql-query="} trim/lines temp/2 {"}] append reb-querys temp ) ] any [ thru <rebscript> copy reb-script to </rebscript> (append reb-scripts trim/lines reb-script) ] any [ thru "<rebout" copy rebout-mod to ">" any [thru "#" copy rebout-var to "#" skip (append rebout-vars rebout-var) ] to </rebout> ] to end ] parse data rule print "Rebout Variable/Parameters" foreach r rebout-vars [print r] print "" print "In-Line REBOL Script stuff" foreach r reb-scripts [print r] print "" print "DB REBOL Query stuff" foreach r reb-querys [print r] print "" print "Goodbye"