Re: [Phplib-users] Template reverse transformation
Brought to you by:
nhruby,
richardarcher
From: nathan r. h. <na...@ds...> - 2003-05-07 20:41:09
|
On Wed, 7 May 2003, Tim Macinta wrote: > Hello Nathan, > > Thanks for your response. > Perhaps it was hot headed. I have several uses who took 'web design classes' from another department who are lost without dreamweaver and imageready, so I get touchy about making things easy for designers sometimes. > I had considered just putting comments at the beginning and end of > templates as you suggested - that may still be an option. It would seem > that is an easy thing to automate, though, and could provide a great > deal of benefit. Having to put comments in each template is a bit of an > inconvenience and opens the door for inconsistency problems if you ever > want to rename your templates, whereas an automated solution would > require no additional effort and would always be up-to-date in the > markers that it prints. > huh? automate the tag insertions and make the script intelligent enough to know how to rename things. The markers would be in a given format and would be (by need) located at the first and last line of every file. the script that generates the markers would already know the filename, so it wouldn't be hard to parse the current marker and correct it if needed. then jsut run the script (either by polling the template directory for chnage, manually, whatever..) This method also allows additional metadata to be added to the markers that you may way (eg: ctime, atime, mtime, cvs info, filesize, etc..) without performance penatly to the end user. > Let me offer an analogy to demonstrate why you would want this. Say you > have a C program that crashes when you run it. How do you fix it? You > recompile with "gcc -g" and re-run the program in a debugger. What if > there was no debug mode? Well, you could put printf statements at the > start and end of every function call so that you know where it crashes, > but that is substantially less convenient and not necessarily as > accurate. > Unless you're a php hacker, then you do the printf() trick :) My issue is that using a 'debug' mode is for debuging, not for actually doing something. This may be semantical, but semantics are important. If you want an additional mode, that fine, but nothing about what you want (at this point) is inherint to the tempalting system.. it's human digestable metatdata about the nugget. > I should also clarify that it's not essential that the whole process be > automated - the Dreamweaver scenario was more of an example than a plan > for how I will use this in practice (I still use Emacs when I edit > HTML). While it would be nice to have a system which automatically > modifies templates based upon modifications to output from those > templates, I think it might be a sufficient first step to have a tool > which takes as input the original HTML page (which was the result of > combining templates) and the modified HTML page (edited in Dreamweaver, > Emacs, or whatever) and prints out a list of what templates you need to > modify and what the diffs are between the original output and the > modified output for each template (ala Gtkdiff). > Honestly, I'd say a first baby step is to generate an editor that takes a template nuggest, wraps it in a fully valid HTML and presents it to a user to be editied and then on submission the actual template ripped out and changes saved. From there you can expand to multiple tempaltes. Gen'ing a diff is easy: $want = $_POST['sometext']; $now = http_get($PHP_SELF); passthru("diff $want $now"); The hard part is figuring out how to disassemble a page and how to deal with inconsistanticies (eg: what happens when a user draws outside the lines? Or takes the lines away becasue they're messy? What happens if a user edits one template that's repeated in the page.. How does the template system know the context that 'Oh.. This user edited the titlebar template, but it was on a foobox, so let's just create a new tempalte for fooboxes and not frob the titlebar template') > When you say that the goal of the PHPLIB template system is to do one > thing well, is that one thing forward template transformations? I guess > what I'm looking for would fall under the umbrella of a template > management which would cover both forward and reverse transformations > (or at least aid in reverse transformations). > Yeah, what you want is a complex template management system. Ideally for it to be really useful, it also need to understand context in some way as well (which is ahrd, becasue you can't really go mucking about with the thing you're going to edit..) and I see a lot of places where it could get tied easily to a implementation (eg: well in blaware we don't do that and never will, so ignore that case..) Right now I'm thinking that php (much less phplib's little tempalte.inc) would have a hard time doing all that and keeping up. not that you can;t use phplib for your project.. I'm jsut not sure that it'd work too well without a substantial rewrite. -n [snip] -- ------ nathan hruby na...@ds... ------ |