Thread: [Phpslash-devel] rfe to template.inc
Brought to you by:
joestewart,
nhruby
From: Mike G. <mi...@op...> - 2003-12-30 14:49:46
|
Hello, Presently Back-End.org is using template.inc as is and adding in template header/footer comments with each template just as phpSlash and (and most other phplib template driven apps likely do). In talking to the Back-end.org team though, it seems like the following modification to template.inc would make it easier for us to ensure that the file names are accurate and easily accessible. cvs diff phplib/php/template.inc Index: phplib/php/template.inc =================================================================== RCS file: /cvsroot/back-end/back-end0.7.x/class/phplib/php/template.inc,v retrieving revision 1.1.1.1 diff -r1.1.1.1 template.inc 909c909,911 < --- > > $str = "<!-- START $filename -->' . $str . '<!-- END $filename -->'; > If we implement this we'll have a lot of header/footer comments to delete and I'd just like to try to keep this in step with phpSlash if we can. I'd also like to contribute the following javascript which can just be inserted into a block to easily identify which templates are where. <script type="text/javascript"> <!-- // Code Contributed by Lasse Nielsen - http://www.infimum.dk function convert(node) { if (!node) {node = document.body;} switch (node.nodeType) { case Node.COMMENT_NODE: var text = node.nodeValue; if (text.substr(0,7)==" START ") { var newNode = createNewNode(text.substr(7)); node.parentNode.replaceChild(newNode,node); } break case Node.ELEMENT_NODE: for (var i=0;i<node.childNodes.length;i++) { convert(node.childNodes[i]); } break; default: break; } } function createNewNode(text) { var a = document.createElement("a"); a.href = "/admin/BE_editTemplateAdmin.php?submit=edit&file="+escape(text); var img = document.createElement("img"); img.src = "/images/BE/buttons/spacer.gif"; a.appendChild(img); return a; } --> </script> <input type="button" value="Convert!" onclick="convert()"> Mike -- Mike Gifford, OpenConcept Consulting Free Software for Social Change -> http://www.openconcept.ca Stop Cdn Pension Plan War Investments -> http://coat.openconcept.ca/ Another world is not only possible, she is on her way -Arundhati Roy |
From: Joe S. <joe...@us...> - 2003-12-30 16:15:37
|
On Tue, Dec 30, 2003 at 09:49:43AM -0500, Mike Gifford wrote: > Hello, > > Presently Back-End.org is using template.inc as is and adding in > template header/footer comments with each template just as phpSlash and > (and most other phplib template driven apps likely do). > > In talking to the Back-end.org team though, it seems like the following > modification to template.inc would make it easier for us to ensure that > the file names are accurate and easily accessible. > I like it if optional or debug type setting. Or if your template editor module can turn display on. I don't like the comments on all production sites. Joe > > cvs diff phplib/php/template.inc > Index: phplib/php/template.inc > =================================================================== > RCS file: > /cvsroot/back-end/back-end0.7.x/class/phplib/php/template.inc,v > retrieving revision 1.1.1.1 > diff -r1.1.1.1 template.inc > 909c909,911 > < > --- > > > > $str = "<!-- START $filename -->' . $str . '<!-- END $filename -->'; > > > > > If we implement this we'll have a lot of header/footer comments to delete and I'd just like to try to keep this in step with phpSlash if we can. > > > I'd also like to contribute the following javascript which can just be inserted into a block to easily identify which templates are where. > > > <script type="text/javascript"> > <!-- > // Code Contributed by Lasse Nielsen - http://www.infimum.dk > function convert(node) { > if (!node) {node = document.body;} > > switch (node.nodeType) { > case Node.COMMENT_NODE: > var text = node.nodeValue; > if (text.substr(0,7)==" START ") { > var newNode = createNewNode(text.substr(7)); > node.parentNode.replaceChild(newNode,node); > } > break > case Node.ELEMENT_NODE: > for (var i=0;i<node.childNodes.length;i++) { > convert(node.childNodes[i]); > } > break; > default: > break; > } > } > > function createNewNode(text) { > var a = document.createElement("a"); > a.href = > "/admin/BE_editTemplateAdmin.php?submit=edit&file="+escape(text); > var img = document.createElement("img"); > img.src = "/images/BE/buttons/spacer.gif"; > a.appendChild(img); > return a; > } > --> > </script> > > <input type="button" value="Convert!" onclick="convert()"> > > > Mike > -- > Mike Gifford, OpenConcept Consulting > Free Software for Social Change -> http://www.openconcept.ca > Stop Cdn Pension Plan War Investments -> http://coat.openconcept.ca/ > Another world is not only possible, she is on her way -Arundhati Roy > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Phpslash-devel mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpslash-devel |
From: Mike G. <mi...@op...> - 2003-12-31 16:25:36
|
Howdy Joe, On Tue, 2003-12-30 at 12:16, Joe Stewart wrote: > On Tue, Dec 30, 2003 at 09:49:43AM -0500, Mike Gifford wrote: > > In talking to the Back-end.org team though, it seems like the following > > modification to template.inc would make it easier for us to ensure that > > the file names are accurate and easily accessible. > I like it if optional or debug type setting. Or if your template editor > module can turn display on. I don't like the comments on all production sites. Glad to know that there is general agreement on: $str = "<!-- START $filename -->' . $str . '<!-- END $filename -->'; I also think that turning the comments on/off would be very useful. I guess it's a matter of being something that is configured within template.inc or passed to template.inc from slashTemplate.class (and probably set in the config.ini.php file).. I'm not sure how you'd make it configurable without something like: function loadfile($varname, $showComments=true) { or perhaps another global variable. I do think the comments should be there by default, but would be awfully nice if they could be turned off in a live site. Mike -- Mike Gifford, OpenConcept Consulting Free Software for Social Change -> http://www.openconcept.ca Stop Cdn Pension Plan War Investments -> http://coat.openconcept.ca/ Another world is not only possible, she is on her way -Arundhati Roy |
From: Matthew L. <lei...@ma...> - 2004-01-10 07:02:39
|
Hi guys, I hope it's not too late to chime in on this, but it seems like this enhancement makes the unnecessary assumption that all templates are HTML-like and use <!-- --> for comments. I have templates that write JavaScript and you can imagine other text formats that can be templated. Why not have template::parse add some variables by default? You'd still have to put them in the templates, but there'd be a standard way to access a template's file name. You can extend PHPLIB's template to do what you want as well. --Matt On 12/30/03 9:49 AM, "Mike Gifford" <mi...@op...> wrote: > Hello, > > Presently Back-End.org is using template.inc as is and adding in > template header/footer comments with each template just as phpSlash and > (and most other phplib template driven apps likely do). > > In talking to the Back-end.org team though, it seems like the following > modification to template.inc would make it easier for us to ensure that > the file names are accurate and easily accessible. > > > cvs diff phplib/php/template.inc > Index: phplib/php/template.inc > =================================================================== > RCS file: > /cvsroot/back-end/back-end0.7.x/class/phplib/php/template.inc,v > retrieving revision 1.1.1.1 > diff -r1.1.1.1 template.inc > 909c909,911 > < > --- >> >> $str = "<!-- START $filename -->' . $str . '<!-- END $filename -->'; >> > > > If we implement this we'll have a lot of header/footer comments to delete and > I'd just like to try to keep this in step with phpSlash if we can. > > > I'd also like to contribute the following javascript which can just be > inserted into a block to easily identify which templates are where. > > > <script type="text/javascript"> > <!-- > // Code Contributed by Lasse Nielsen - http://www.infimum.dk > function convert(node) { > if (!node) {node = document.body;} > > switch (node.nodeType) { > case Node.COMMENT_NODE: > var text = node.nodeValue; > if (text.substr(0,7)==" START ") { > var newNode = createNewNode(text.substr(7)); > node.parentNode.replaceChild(newNode,node); > } > break > case Node.ELEMENT_NODE: > for (var i=0;i<node.childNodes.length;i++) { > convert(node.childNodes[i]); > } > break; > default: > break; > } > } > > function createNewNode(text) { > var a = document.createElement("a"); > a.href = > "/admin/BE_editTemplateAdmin.php?submit=edit&file="+escape(text); > var img = document.createElement("img"); > img.src = "/images/BE/buttons/spacer.gif"; > a.appendChild(img); > return a; > } > --> > </script> > > <input type="button" value="Convert!" onclick="convert()"> > > > Mike -- |
From: Mike G. <mi...@op...> - 2004-01-10 17:40:19
|
Hi Matthew, We ran into that problem with the text templates... Evan suggested a regex work around like: s/<!-- START .*?\.tpl -->// s/<!-- END .*?\.tpl -->// could be applied to the template.. Having a {START_TEMPLATE} {END_TEMPLATE} header to stick into the template files sounds fine.. Just need to find someone to integrate it and propose a patch.. Mike On Sat, 2004-01-10 at 02:02, Matthew Leingang wrote: > Hi guys, > > I hope it's not too late to chime in on this, but it seems like this > enhancement makes the unnecessary assumption that all templates are > HTML-like and use <!-- --> for comments. I have templates that write > JavaScript and you can imagine other text formats that can be templated. > > Why not have template::parse add some variables by default? You'd still > have to put them in the templates, but there'd be a standard way to access a > template's file name. > > You can extend PHPLIB's template to do what you want as well. > > --Matt > > On 12/30/03 9:49 AM, "Mike Gifford" <mi...@op...> wrote: > > > Hello, > > > > Presently Back-End.org is using template.inc as is and adding in > > template header/footer comments with each template just as phpSlash and > > (and most other phplib template driven apps likely do). > > > > In talking to the Back-end.org team though, it seems like the following > > modification to template.inc would make it easier for us to ensure that > > the file names are accurate and easily accessible. > > > > > > cvs diff phplib/php/template.inc > > Index: phplib/php/template.inc > > =================================================================== > > RCS file: > > /cvsroot/back-end/back-end0.7.x/class/phplib/php/template.inc,v > > retrieving revision 1.1.1.1 > > diff -r1.1.1.1 template.inc > > 909c909,911 > > < > > --- > >> > >> $str = "<!-- START $filename -->' . $str . '<!-- END $filename -->'; > >> > > > > > > If we implement this we'll have a lot of header/footer comments to delete and > > I'd just like to try to keep this in step with phpSlash if we can. > > > > > > I'd also like to contribute the following javascript which can just be > > inserted into a block to easily identify which templates are where. > > > > > > <script type="text/javascript"> > > <!-- > > // Code Contributed by Lasse Nielsen - http://www.infimum.dk > > function convert(node) { > > if (!node) {node = document.body;} > > > > switch (node.nodeType) { > > case Node.COMMENT_NODE: > > var text = node.nodeValue; > > if (text.substr(0,7)==" START ") { > > var newNode = createNewNode(text.substr(7)); > > node.parentNode.replaceChild(newNode,node); > > } > > break > > case Node.ELEMENT_NODE: > > for (var i=0;i<node.childNodes.length;i++) { > > convert(node.childNodes[i]); > > } > > break; > > default: > > break; > > } > > } > > > > function createNewNode(text) { > > var a = document.createElement("a"); > > a.href = > > "/admin/BE_editTemplateAdmin.php?submit=edit&file="+escape(text); > > var img = document.createElement("img"); > > img.src = "/images/BE/buttons/spacer.gif"; > > a.appendChild(img); > > return a; > > } > > --> > > </script> > > > > <input type="button" value="Convert!" onclick="convert()"> > > > > > > Mike -- Mike Gifford, OpenConcept Consulting Free Software for Social Change -> http://www.openconcept.ca Stop Cdn Pension Plan War Investments -> http://coat.openconcept.ca/ Another world is not only possible, she is on her way -Arundhati Roy |