|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
yankee Smarty Rookie
Joined: 02 Mar 2009 Posts: 31
|
Posted: Sat Mar 07, 2009 7:37 am Post subject: "comment placeholder" |
|
|
internal.templateparser.y line 90:
Code: | template_element(res)::= COMMENTSTART text(t) COMMENTEND. { res = $this->cacher->processNocacheCode('<?php /* comment placeholder */?>', $this->compiler,false,false);} |
This will insert a comment placeholder when there is a comment in the template file.
This looks pretty pointless to me. For debugging purposes it might be useful to have the comments inserted into the compiled template file which can be done with this untested patch:
Code: | Index: Smarty3Alpha/libs/lexer/internal.templateparser.y
===================================================================
--- Smarty3Alpha/libs/lexer/internal.templateparser.y (revision 3023)
+++ Smarty3Alpha/libs/lexer/internal.templateparser.y (working copy)
@@ -87,7 +87,7 @@
res = $this->cacher->processNocacheCode($tmp.st, $this->compiler,$this->nocache,true);
} $this->nocache=false;}
// comments
-template_element(res)::= COMMENTSTART text(t) COMMENTEND. { res = $this->cacher->processNocacheCode('<?php /* comment placeholder */?>', $this->compiler,false,false);}
+template_element(res)::= COMMENTSTART text(t) COMMENTEND. { res = '/*'.str_replace('*/', '', t).'*/';}
// Literal
template_element(res)::= LITERALSTART text(t) LITERALEND. {res = $this->cacher->processNocacheCode(t, $this->compiler,false,false);}
// {ldelim}
|
But in normal scenarios the comments can just be dropped since the compiled templates are not intended for beeing read by humans anyway. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Mar 09, 2009 3:11 pm Post subject: |
|
|
You can now configure template comment handling:
$smarty->comment_mode = 0; (default)
The comments will be removed
$smarty->comment_mode = 1;
The comments will be replaced by a place holder
$smarty->comment_mode = 2;
The comments will be passed to the compiled template.
NOTE: If you change the setting you must recompile the templates. |
|
Back to top |
|
yankee Smarty Rookie
Joined: 02 Mar 2009 Posts: 31
|
Posted: Mon Mar 09, 2009 3:30 pm Post subject: |
|
|
ok...
But I suggest using constants instead, to increase readability of code...
Code: | $smarty->comment_mode = Smarty::COMMENTS_REMOVE;
$smarty->comment_mode = Smarty::COMMENTS_REPLACE_WITH_PLACEHOLDER;
$smarty->comment_mode = Smarty::COMMENTS_PASS_THRU; |
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Mar 09, 2009 3:36 pm Post subject: |
|
|
After a discussion with Monte we just decided to remove this feature and generally remove all comments and don't also not replace them by place holders. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|