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

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  

Which syntax you like?
{tag--}
50%
 50%  [ 1 ]
{tag>>}
50%
 50%  [ 1 ]
{tag<<}
0%
 0%  [ 0 ]
Total Votes : 2

Author Message
VEG
Smarty Rookie


Joined: 02 May 2010
Posts: 20
Location: Belarus

PostPosted: Fri Apr 19, 2013 6:03 am    Post subject: Whitespace control in Smarty 3.2 Reply with quote

Code:
Whitespaces in front or after tags can now be controled by the tag itself.
{-tag} remove white space infront of tag up to the previous non-whitespace character or beginning of the line
"text \n\n\t {-tag}" -> "text \n\n{tag}"
"text \n\n\t text\t {-tag}" -> "text \n\n\t text{tag}"
{--tag} remove white space infront of tag up to the previous non-whitespace character
"text \n\n\t {--tag}" -> "text{tag}"
"text \n\n\t text\t {--tag}" -> "text \n\n\t text{tag}"
{tag-} remove white space after tag up to the next non-whitespace character or end of the line
"{tag-} \n\n\t text" -> "{tag}\n\n\t text"
"{tag-} text \n\n\t text" -> "{tag}text \n\n\t text"
{tag--} remove white space after tag up to the next non-whitespace character
"{tag--} \n\n\t text" -> "{tag}text"
"{tag--} text \n\n\t text" -> "{tag}text \n\n\t text"

I think that {$var--} looks a little weird. Maybe better to use different syntax?

For example:
Code:

{<tag} instead of {-tag}
{<<tag} instead of {--tag}
{tag>>} instead of {tag--}
{tag>} instead of {tag-}
{<>} (remove spaces before and after this construction)
{<} (remove spaces only before this construction)
{<<>>}  (remove spaces and newlines before and after this construction)
{<>>}  (remove spaces before, and spaces+newlines after this construction)


Or another variant inspired by the </li><li>:
Code:

{><} (remove spaces before and after this construction)
{>} (remove spaces only before this construction)
{>><<}  (remove spaces and newlines before and after this construction)
{><<}  (remove spaces before, and spaces+newlines after this construction)
{>tag} instead of {-tag}
{>>tag} instead of {--tag}
{tag<<} instead of {tag--}
{tag<} instead of {tag-}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 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