Re[2]: Incorrect newline counters
Dmitry Koteroff <[email protected]>
| Newsgroups | gmane.comp.php.smarty.devel |
|---|---|
| Message-ID | <[email protected]> |
MO> I think (someone correct me if this isn't right) custom
MO> functions must produce their own newlines if they need them.
I'll correct. (-;
How would they know if they need to emit \n?
How would user-defined function know if it is situated in the
middle of the line or at the end of line?
I see only two ways to solve the problem:
1. pass each function additional parameter (it's too bad), and
2. move \n insertion from compile-time to runtime.
Seems there are no other solutions.
MO> Dmitry Koteroff wrote:
>>MO> I think this rule works: If a tag produces no output, then no
>>MO> newline should be produced by it.
>>Good concept.
>>
>>But HOW to determine which function is "pure" and which - is not?
>>It also touches user-defined functions (!), of course (for
>>built-in we can point it manually, it's not interesting).
>>
>>Maybe if function returns NULL (of ralse) it may be considered as
>>pure?
>>
>>NULL is returning at run-time, but we have to detect if we need
>>\n at COMPILE-time. Maybe simply displace this functionality to
>>runtime?
>>
>>
>>MO> examples:
>>MO> {$foo}
>>MO> {$foo2}
>>MO> {$foo3}
>>MO> The above vars should make newlines in the resulting template since they
>>MO> have output (even if it's empty).
>>MO> {assign var="foo" value="bar"}
>>MO> {assign var="foo2" value="bar2"}
>>MO> {assign var="foo3" value="bar3"}
>>MO> {if ...}
>>MO> {/if}
>>MO> {include ...}
>>MO> The above functions should NOT make newlines in the resulting template,
>>MO> there is no output. They are purely functional.
>>
>>MO> Dmitry Koteroff wrote:
>>
>>
>>
>>>>MO> I'd say in theory, any function on a line **by itself** that does not
>>>>MO> produce output directly should not create a line in the output. So, #2
>>>>MO> would probably be the expected output. Similar example:
>>>>MO> {if $foo}
>>>>MO> bar
>>>>MO> {/if}
>>>>MO> should output:
>>>>MO> bar\n
>>>>MO> and not:
>>>>MO> \nbar\n\n
>>>>Stop. It is identical to PHP's behaviour:
>>>>
>>>><?if (...) {?>
>>>>bar
>>>><?}?>
>>>>
>>>>Result is "bar\n".
>>>>
>>>>But you had said before that newlines MUST not be ignored after
>>>>{...} constructions!
>>>>
>>>>Can you explain this? Maybe newlines must be always deleted after
>>>>block-tags, but not after function-tag?
>>>>
>>>>Can you explain the FULL behavour of different tags?
>>>>
>>>>
>>
>>
>>
--
Best regards,
Dmitry Koteroff.
--
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php