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

[REBOL] PATCH: build-tag function

From: robert::muench::robertmuench::de at: 9-Jan-2005 19:01

Librarian comment

build-tag  is now a supported function within recent releases of REBOL.

Hi, here is a patched BUILD-TAG function. The main difference to the original version is that if the value part is NONE no, attribute will be included. This makes creating HTML tags much simpler. Example: action: script.cgi method: none Old: build-tag [form action (action) method (method)]
>> <form action="script.cgi" method="none">
New: build-tag [form action (action) method (method)]
>> <form action="script.cgi">
build-tag: func [ "Generates a tag from a composed block." values [block!] "Block of parens to evaluate and other data." /local tag value-rule xml? name attribute value] [ tag: make string! 7 * length? values value-rule: [ set value issue! (value: mold value) | set value file! (value: replace/all copy value #" " " ") | set value any-type! ] xml?: false parse compose values [ [ set name ['?xml (xml?: true) | word!] (append tag name) any [ set attribute [word! | url!] value-rule ( if found? value [repend tag [#" " attribute {="} value {"}]] ) | value-rule (if found? value [repend tag [#" " value]]) ] end (if xml? [append tag #"?"]) ] | [set name refinement! to end (tag: mold name)] ] to tag! tag ] -- Robert M. M=FCnch Management & IT Freelancer Mobile: +49 (177) 245 2802