Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

nested comments

 
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
bolero
Smarty Rookie


Joined: 22 Nov 2010
Posts: 30

PostPosted: Fri Dec 10, 2010 12:41 pm    Post subject: nested comments Reply with quote

Every so often I come over some longer piece of template code that I would like to comment out temporarily or comment out "for real" but preserve for a longer time. The current {* *} doesn't allow putting it as a wrap around that code. I assume there is a problem with finding the end of the comment. What about using the same open and close syntax as with other Smarty elements?

Code:
{* ... /*} comment that can contain other Smarty elements.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Dec 10, 2010 2:51 pm    Post subject: Reply with quote

you can't nest the comment tags, too many problems. Its the same in PHP with /* */ blocks, you can't nest them since the ending tags are ambiguous. You could do a work around though, make up your own comment tag syntax:

Code:
{***
   Put any {* smarty *} stuff {in} here.
***}


Then use a prefilter to snip out these comment blocks before compile time. Something like:

Code:
return preg_replace('!\{\*\*\*.*\*\*\*\}!Ums','',$content);
Back to top
View user's profile Send private message Visit poster's website
bolero
Smarty Rookie


Joined: 22 Nov 2010
Posts: 30

PostPosted: Thu Dec 16, 2010 6:41 pm    Post subject: Reply with quote

Ok, maybe "nested" comments was the wrong term. I mean a mix of comments and code. What I want is exactly the same that I can do with /* */ in php. Just put them around any code block and it's commented out. This doesn't really work with Smarty. (I'm ok with comments not allowed within comments.)

e.g., that works:
Code:
{* some text here *}


that sometimes does, but sometimes does not:

Code:

{*
{lenghty smarty code block including text and html}

*}


I can't give you an example at the moment. I just ran into this problem regularly with Smarty 2 and found that it still happens with Smarty 3 the day I posted it. As I understand wrapping the smarty code with {* *} should always work, just not if another comment is contained, right?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Dec 16, 2010 8:19 pm    Post subject: Reply with quote

That should work. A demonstration of the problem would be a big help.
Back to top
View user's profile Send private message Visit poster's website
bolero
Smarty Rookie


Joined: 22 Nov 2010
Posts: 30

PostPosted: Mon Dec 20, 2010 5:33 pm    Post subject: Reply with quote

Ok, next time I run into it I'll add here. Of course, it's possible that I accidentally had a nested comment somewhere in that code. We'll see. Happy holdays!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP