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


From: oliva::david::seznam::cz at: 5-Aug-2002 9:07

Hello Carl, Saturday, August 3, 2002, 6:08:19 AM, you wrote: CaR> Some of the changes include: CaR> Added BUILD-MARKUP Function Nice function, but what about this small improvement: build-markup: func [ {Return markup text replacing <%tags%> with their evaluated results.} content [string! file! url!] /quiet "Do not show errors in the output." /with {Starting and ending tags - by default it's "<%" and "%>"} mstart [string!] mend [string!] /local out eval value ][ content: either string? content [copy content] [read content] out: make string! 126 if not with [mstart: "<%" mend: "%>"] eval: func [val /local tmp] [ either error? set/any 'tmp try [do val] [ if not quiet [ tmp: disarm :tmp append out reform ["***ERROR" tmp/id "in:" val] ] ] [ if not unset? get/any 'tmp [append out :tmp] ] ] parse/all content [ any [ end break | mstart [copy value to mend 2 skip | copy value to end] (eval value) | copy value [to mstart | to end] (append out value) ] ] out ] so we can choose starting and ending tags:
>> build-markup {now is: <%now%>}
== "now is: 5-Aug-2002/8:47:53+2:00"
>> build-markup/with {now is: <#now#>} "<#" "#>"
== "now is: 5-Aug-2002/8:55:01+2:00" You may think, that it's not usefull, but what if someone want to preprocess some PHP or ASP code where the default tags (<% %>) are used as well? But maybe nobody will need it and if someone will need it, may replace the build-markup function with this one or other:-) --oldes