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

Looking For Help

 [1/5] from: jrichards10:adelphia at: 29-Jan-2003 5:04


Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi All,=0D =0D I am looking for some help on a simple problem I am having.=0D =0D I am trying to read in an html template file and do variable substitution=2E In what format should the template file be in for this to be accomplished=2E I have tried several different methods but I cannot get the variables to print.=0D =0D Thanks=0D =0D Sales Associate=0D New England Computer Remarketing=0D 14 Industrial Way=0D Atkinson, NH 03811=0D (603) 893-2091 -- Binary/unsupported file stripped by Listar -- -- Err : No filename to use for decode, file stripped. -- Type: image/gif -- Binary/unsupported file stripped by Listar -- -- Err : No filename to use for decode, file stripped. -- Type: image/jpeg

 [2/5] from: petr:krenzelok:trz:cz at: 29-Jan-2003 12:30


Hi, although I don't know any details about how you use templates etc., I will elaborate a bit. Rebol does know how to deal with scripts embedded into websites. You can find some info upon latest releases here: http://www.reboltech.com/downloads/changes.html - look for build-tag and build-markup functions and code examples ... However - that is not sufficient model for me. I strictly require division between database information maintainer, web designer and web programmer. That is not currently easily possible, unless programmer sends each time his work to web designer. Current aproach also limits webdesigner into how he/she designs webpage. He/she can't see the design, if e.g. you are required to build-table by script. Then your code has to carry also design information ... Build-markup is nearly there, but not exactly there :-) Simply everything in between: *<% email %> * is being evaluated ... But whole your .html file is treatened as one context. What happens if you have several tables in one html file, and need two 'email words? I don't want to use e.g. <%user/email%> and <%company/email%>. I will soon try to design following aproach - encapsulated modules, which know how to behave. So - website designer marks start and end of module <!--[module: "abc" version: 1.0.2 config: [dialect here]]--> I am not sure it will look exactly that way, but it will be something like that. I can even go for component/modules architecture (plug-ins). My first example will be - tables. I want to give designer a freedom, so he/she can e.g. design whole table design, and mark certain sections for me. Or he can just desing one row of table, and instruct me to repeat the rows and take amount of rows from cgi variable or directly from dialect. Does your designer want to go for two tables design, change color, style, etc.? Who cares? Let him do so, my module should know how to parse his/her requirements ... Later on, for some environments, some plug-ins could be created to allow configuration of module .... So, that is how I am thinking about the problem. I yet have to implement it. Our first kiosk system is running, and now is time for a little abstraction. I will try to implement what I described, but maybe I will fail, as there seem to be noone else here thinking in the same way and maybe the code will be too have and complex, difficult to use - who knows :-) Cheers -pekr- Jim Richards wrote:

 [3/5] from: joel:neely:fedex at: 29-Jan-2003 7:32


Hi, Jim, No "should", just lots of possibilities... ;-) Jim Richards wrote:
> Content-Type: Text/Plain; > charset="iso-8859-1"
<<quoted lines omitted: 6>>
> accomplished? I have tried several different methods but I > cannot get the variables to print.
Here's one possibility: 8<---- begin "html-template.r" ---- REBOL [] html-template: make object! [ var-name: none var-rule: [{variable name="} copy var-name to {"} to end] template: none load-template: func [f [file! string!]] [ template: load/markup to-file f ] fill-template: func [data [block!] /local result] [ result: copy "" foreach item template [ append result either all [ tag? item parse item var-rule ][ any [select data var-name ""] ][ item ] ] result ] process: func [f [file! string!] vars [block!]] [ load-template f fill-template vars ] ] 8<---- end "html-template.r" ---- 8<---- begin "sample.html" ---- <html> <head><title><variable name="title"/></title></head> <body> <h1><variable name="title"/></h1> <p><variable name="para1"/></p> <p><variable name="para2"/></p> </body> </html> 8<---- end "sample.html" ---- ... which behaves as follows ...
>> do %html-template.r
Script: "Untitled" (none)
>> print html-template/process %sample.html [
[ "title" "Testing 1, 2, 3" [ "para1" "This is a test." [ "para2" "Hello, world!" [ ] <html> <head><title>Testing 1, 2, 3</title></head> <body> <h1>Testing 1, 2, 3</h1> <p>This is a test.</p> <p>Hello, world!</p> </body> </html>
>>
Of course, you can build the name/value block in whatever fashion is appropriate for your application, and then call the PROCESS method on HTML-TEMPLATE once you've built all of your content pieces. HTH! -jn-

 [4/5] from: joel::neely::fedex::com at: 29-Jan-2003 7:48


Hi, Petr, Interesting comments, as usual! How about a simple first step (see below)? Petr Krenzelok wrote:
> However - that is not sufficient model for me. I strictly require > division between database information maintainer, web designer and > web programmer... >
...
> But whole your .html file is treatened as one context. What happens if > you have several tables in one html file, and need two 'email words? I > don't want to use e.g. <%user/email%> and <%company/email%>. >
Using the HTML-TEMPLATE from my previous reply, one could use something like the following quick kludge: 1) create three template html files: a) one for a "typical row" b) one for the entire table "wrapper" c) one for the entire page 2) create a table-maker wrapper for HTML-TEMPLATE that would take the first two templates and a data source as arguments, and would: a) initialize a content accumulator string to empty, b) iterate through the data source, filling in the "typical row" template for each chunk of source data (e.g. row of database) with appropriate pre-processing, and append the result of each iteration to the content accumulator, c) upon completion, fill in the table "wrapper" template with the content accumulator's value. 3) use the result of step (2) as a single value for the name/value pairs to fill in the entire page template. Of course, step (2) could be repeated as often as needed for multiple tables within a single page, saving each table image under a different name in the page's name/value block. With all that said... The above approach strikes me as a bit like "assembly language" where the programmer has to tie everything together and follow all of the appropriate conventions. It would be feasible IMHO either: 1) to extend the template notation to allow a page layout expert to create a single page meta-template that would use additional markup to show embedded structure, then a pre-process to break that meta-template up into the collection of individual templates used as above, or 2) build up the structure in code to take the meta-template and use HTML-TEMPLATE as a low-level block to assemble an entire page at a time, or 3) to stay with the above approach, given that one could define a "flavor" of table/row combination once and re-use that same piece of design across multiple pages. Just for thinking about... -jn-

 [5/5] from: petr:krenzelok:trz:cz at: 29-Jan-2003 16:02


Joel Neely wrote:
>Hi, Petr, > >Interesting comments, as usual! > >How about a simple first step (see below)? >
Well, I already did some first step, but it simply hardwires values into website source :-) We use: <!--Snowhill_name_start-->something here ...<!--end--> we simply look for certain section, replace data, begin to head of document to perform another section look-up .... now to your comments ....
>Using the HTML-TEMPLATE from my previous reply, one could use something >like the following quick kludge: > >1) create three template html files: > > a) one for a "typical row" > b) one for the entire table "wrapper" > c) one for the entire page >
yes - that is what I meant by component/modules or modules/sub-modules (plug-ins). The module would be still called e.g. "table" and your typical row etc. values would be part of module config dialect, e.g. <!--[ module: "abc" version: 1.0.2 config: [ table-style typical-row repeat 2 rows ; different colors for first and second row, repeat those pairs times in cgi num-rows ; take number of rows from cgi env. variable .... ] ]-->
>2) create a table-maker wrapper for HTML-TEMPLATE that would take the > first two templates and a data source as arguments, and would:
<<quoted lines omitted: 5>>
> c) upon completion, fill in the table "wrapper" template with the > content accumulator's value.
hey, that's cute aproach! I will add it to list of the things to think about :-) There is of course many ways of how to use templates, what would have designer to do, how/where he/she would put template instructions into html source, how to easily maintain it on the server's side etc etc.
>3) use the result of step (2) as a single value for the name/value pairs > to fill in the entire page template.
<<quoted lines omitted: 16>>
> "flavor" of table/row combination once and re-use that same piece > of design across multiple pages.
Now I am lost with 1) and 2), but never mind :-) thanks for input, -pekr-

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted