[REBOL] html4 generator script Re:(2)
Thanks for the suggestions, Elan. I'm using the gentag function internally to create a block of name/value pairs that eventually gets printed with build-tag, i.e., print [build-tag [h1 (tag)]]. The gentag function seems inefficient to me. Also I noticed that if I set the events property of an object like this: h1/events: ['onMouseOver {message('Entered this H1 tag');return true} 'onMouseOut {message('');return true}] the resulting tag looks like this: h1 events onMouseOver="message('Entered this H1 tag');return true" onMouseOut="message('');return true" Note the word 'events' inside the tag. This doesn't seem to bother IE, but it's not correct html either. I think I can fix this problem. I'm open to any suggestions.Thanks Scott From: [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [REBOL] html4 generator script Re: Date: Thu, 24 Feb 2000 16:39:42 -0800 Hi Scott, I briefly glanced at your html4.r script. (Briefly means that I may have few more ideas when I take a close look). __ Get Your Private, Free Email at http://www.hotmail.com
[REBOL] html4 generator script Re:
Hi Scott, I briefly glanced at your html4.r script. (Briefly means that I may have few more ideas when I take a close look). Some observations: You use print throughout in your functions. That will significantly slow down your output to the webserver. Instead, have each function return a string that contains the stuff you would have usually printed out. I.e in this example: Begin: func ["The HTML tag."][ print [HTML] ] use: begin: func [] [ return "HTML" ] In this example: _head: make object! [ http-equiv: none author: none keywords: none description: none title: none style: none out: func [][ print [HEADnewline] if (not none? http-equiv) [print build-tag [meta http-equiv (http-equiv)]] if (not none? author) [print build-tag [meta name "AUTHOR" content (author)]] if (not none? keywords) [print build-tag [meta name "KEYWORDS" content (keywords)]] if (not none? description) [print build-tag [meta name "DESCRIPTION" content (description)]] if (not none? style) [ print build-tag [style type "text/css"] print [style newline /STYLE]] if (not none? title) [print [{TITLE}title{/TITLE}newline{/HEAD}]] ] end: func [] [print [/HEAD]] ] ; end of _head object TRY INSTEAD: _head: make object! [ tags: make object! [ http-equiv: none author: none keywords: none description: none title: none style: none ] out: func [/local result meta-block][ result: make string! 1000 foreach tag next first tags [ if get in tags tag [ append result either meta-block: select [ http-equiv [http-equiv] author [name "AUTHOR"] keywords [name "KEYWORDS"] description [name "DESCRIPTION"] ] tag [ build-tag compose/deep [meta (meta-block) content (get in tags tag)] ][ switch tag [ style [ rejoin [ build-tag [tags/style type "text/css"] tags/style newline "/STYLE" ] ] title [ rejoin ["TITLE" tags/title " /TITLE /HEAD"] ] ] ] append result newline ] ] return head insert result HEAD ] ] To have a complete (albeit trivial) web page let me add the following strings: content-type: "Content-Type: text/ ^/^/" end-html: /HTML body: "BODY/BODY" In your CGI script you the say: _head/tags/http-equiv: "Whatever" _head/tags/author: "Elan" _head/tags/keywords: {REBOL programming consult web page design software programs} _head/tags/description: {Programmer and consultant web page} _head/tags/title: {Think First Consulting} _head/tags/style: none print [ content-type _head/out body end-html ] If I print mold _head/out I get: {HEADmeta http-equiv content="Whatever" meta name="AUTHOR" content="Elan" meta name="KEYWORDS" content="REBOL programming consult web page design software programs" meta name="DESCRIPTION" content="Programmer and consultant web page" TITLEThink First Consulting /TITLE /HEAD } Perhaps it would be a better idea to use html-head instead of _head? It's more user friendly and even a novice will immediately understand what you are talking about. ;- Elan [: - )]