|
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 |
sarahfoxnz Smarty Regular
Joined: 11 Apr 2010 Posts: 76
|
Posted: Sat Nov 19, 2016 11:44 am Post subject: Strip tag to only remove blank lines? |
|
|
EDIT, i am aware my 'output' should not contain Smarty code - but i hope you understand what Im after.
http://www.smarty.net/docsv2/en/language.function.strip.tpl
Hello.
I do know the above strip command, however i was wondering if there was a command to remove blank lines from the output WITHOUT putting the 2nd/3rd line on the same line as the first...
I want the html code to remove blank lines - But keep the 2nd line on the 2nd line...
example :- ORIGINAL
Code: |
{* the following will be all run into one line upon output *}
{strip}
<table border='0'>
<tr>
<td>
<a href="{$url}">
<font color="red">This is a test</font>
</a>
</td>
</tr>
</table>
{/strip}
|
The STRIP command does this :-
Code: |
{* the following will be all run into one line upon output *}
{strip}
<table border='0'><tr><td><a href="{$url}"><font color="red">This is a test</font></a></td></tr></table>
{/strip}
|
What im after - is this :-
Code: |
{* the following will be all run into one line upon output *}
{strip}
<table border='0'>
<tr>
<td>
<a href="{$url}">
<font color="red">This is a test</font>
</a>
</td>
</tr>
</table>
{/strip}
|
Has smarty got a command that has this ability ? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
sarahfoxnz Smarty Regular
Joined: 11 Apr 2010 Posts: 76
|
Posted: Sat Nov 19, 2016 12:23 pm Post subject: |
|
|
Thanks..
i guess i'll have to live with the multiple spaces, or hunt them down & remove them...
(im not after 'pretty' - Just to remove excess spaces)
PS the FONT tag was/is shown in your smarty documentation (test)...
http://www.smarty.net/docsv2/en/language.function.strip.tpl |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Nov 19, 2016 12:29 pm Post subject: |
|
|
{strip} removes excess whitespaces BETWEEN the start and end tags.
I don't understand your "have to live with the multiple spaces". Sorry.
Code: | <?php
require_once 'smarty-config.php';
$smarty->display(__FILE__);
__HALT_COMPILER();
?>{strip}
<table border='0'>
<tr>
<td>
<a href="{$url}">
<font color="red">This is a test</font>
</a>
</td>
</tr>
</table>
{/strip} |
Code: | $ php -f ./strip.php 2> nul
<table border='0'><tr><td><a href=""><font color="red">This is a test</font></a></td></tr></table>
|
|
|
Back to top |
|
sarahfoxnz Smarty Regular
Joined: 11 Apr 2010 Posts: 76
|
Posted: Sat Nov 19, 2016 2:22 pm Post subject: |
|
|
AnrDaemon wrote: | {strip} removes excess whitespaces BETWEEN the start and end tags.
I don't understand your "have to live with the multiple spaces". Sorry.
|
The thing i do want, i cannot have - So i have to live with it (what i dont have)....
AnrDaemon wrote: |
[code]
[code]$ php -f ./strip.php 2> nul
<table border='0'><tr><td><a href=""><font color="red">This is a test</font></a></td></tr></table>
[/code] |
Thats what i do not want - i dont want 5,10,20+ HTML commands all in one paragraph/line of text.....
I want each line of my HTML code on each / separate line of HTML source code (if i look at the source code of HTML output)... HOWEVER - any blank lines (with no text or html code) to be removed.
NOTE: if I put 2 or more HTML commands onto one line - then thats my problem, 2 html commands of HTML code will display on the one line...
if i have 3 HTML comands in one line - it will display 3 html commands - i dont need/want the smarty compiler to determine where to split html commands..
if i have 10 lines of codes - But 5 lines are blank/un-used, i will get 5 lines of code as a result - the blank lines are removed... |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
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
|