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

[REBOL] long mail, sorry. RE: Re: Parse refactoring puzzle

From: maximo::meteorstudios::com at: 1-Aug-2003 10:37

Hi, sunanda, I have been following this thread silently, but now that steel is public I will give you a little primer on the remark.r tool. REMARK.R is a complete html markup extension engine. Basically whenever the engine encounters one of the tag extensions, it recursively parses it and replaces the tag with whatever data is returned by that tag's local build-html function. What I like is that because the tags follow the html <> useage, they look just right in the html code and can easily be spotted. there are two distinct tag extension mechanisms: HTAGS: The system allows you to add new tags at will , just by adding files to a directory and then putting the html text you want in those files. Even though the htags are static code on disk, because the engine parses them at run-time, you can add dynamic tags in the static pages layout, and they will also be replaced, recursively. RTAGS: Dynamic tags which actually call some methods on user-defined prebuilt tags descriptors. for example <date!> replaces itself with the current date (at build time). You can add any amount of tags, just by adding an object in the rtags file. you can also supply additional parameters to rtags. I'll follow with more details, explanations and examples: --------------------------------------------------------- If you have a htag saved as footer.html which has this content: <p3><i>site updated on <date!></i></p> and you have a src html file which includes the following in it: <body> <p> some very usefull text right here... ;-) </p> <footer!> </body> then the system will first build the html code for the footer! tag (copying the footer.html content) it will then call the replace-tags on that code block, so that the <date!> will also be replaced. this goes on foreach tag extension it finds. by using rtags, I have even created a tag called <rebol! > which lets you execute rebol code right there and then, and uses the return value as the code! so the <date!> rtag could easily be coded like this too <rebol! now/date> The only thing which is not yet implemented (but which could be done easily) is to tie it up as a cgi executable OR to allow it to use data files or a databse as instead of prebuilt src html files. a work around would be something like a file with following contents: <rebol! global-values: make object! [name: "mr bright" age: 34 fav_color: blue] ""> <greeting-page!> and have a greeting-page.html in your htags directory which looks like so. <html> <body> <p> hello <username!> , </p> <p>your favorite color is <favcolor!> <agetext!>.</p> </body> </html> As you imagine <username!> <favcolor!> <agetext!> would be rtags which look up an object called global-values and return its data with some formatting if you want. to make it even more flexible, you might want to replace the previous source html by: <your-look-up-database-func! "mr. bright" ""> <greeting-page!> the look-up-database! would then be a function which fills the global-values with db data. If your cgi script writes the src-file to disk, calls remark.r and returns the generated file, you could use it for cgi right now. THe steel site uses it for each page... for an example of an advanced rtag, you may notice that the menu on the upper right changes depending on the item you clicked on (the current file is red and does not containt a link, since you are already on the file).. The menu <mainmenu!> is inserted in my header htag and is defined elsewhere and is an <rmenu!> tag. here is my complete html code for the steel's news page before it goes through remark: (I remove most of the contents, though) <header!> <h3>NEWS!</h3> <h4 class="newstitle">2003/07/30 - Site Creation</h4> [... NEWS CONTENT DATA HERE!!! ...] <BR> <BR> <BR> <BR> <BR> <custfooter!> you can see that I do not have to concentrate on the layout, its all in my header and footer htags. Since the header contains the menu, one is added to each page in the site. remark.r will be available next week, with some documentation and example site I hope. Its part of the retool section on the steel website. HTH! -max ----------- meteor Studios, T.D. ----------- Never Argue with an idiot. They will bring you down to their level and beat you with experience