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


From: al:bri:xtra at: 6-Aug-2002 16:28

RebOldes wrote:
> 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 mend | copy value to end] (eval value) | copy value [to mstart | to end] (append out value) ] ] out ] I've made a slight improvement in the 'parse rule, changing the "2 skip" to mend , so as to allow variable length ending tag. Using a fixed length is asking for trouble! :) I've sent it to feedback as well. Andrew Martin ICQ: 26227169