SitePoint Sponsor

User Tag List

Page 2 of 4 FirstFirst 1234 LastLast
Results 26 to 50 of 94
  1. #26
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No, it isn't any specific feature that classes it as a template system, it's just part of what it was designed for.

  2. #27
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP is a templating engine by itself. Adding another templating engine on top of it just doesn't make sense. The only situation where it makes sense, is when you don't trust the template to contain nice behaving code.
    - Rasmus Lerdorf
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #28
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Designers can screw up a smarty template just as easily as a php one...

  4. #29
    SitePoint Addict
    Join Date
    Jun 2008
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    No, it isn't any specific feature that classes it as a template system, it's just part of what it was designed for.
    So why do people call it a template system then?

  5. #30
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by F.Danials View Post
    So why do people call it a template system then?
    ...

    Quote Originally Posted by Stormrider View Post
    it's just part of what it was designed for.

  6. #31
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by F.Danials View Post
    So why do people call it a template system then?
    PHP is a templating engine by itself.
    If Ramus Lerdorf -- the creator of the PHP -- calls it a template engine, its a template engine >.>...
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  7. #32
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginethis View Post
    It's not an opinion, its a fact.
    No, it's an opinion. A templating engine would be "redundant" if it did not have advantages of its own. However, a good one does.

    Quote Originally Posted by imaginethis View Post
    PHP Code:
    <? foreach($users as $user): ?>
    <a href="/<?= htmlspecialchars($user?>">
      <?= htmlspecialchars($user)?>
    </a>
    <? endforeach; ?>
    Not so hard on the eyes. This is hardly much more than what you'd have in smarty. It's not hard to write and there's no ugly spaghetti code to "waddle" through.
    You shouldn't depend on <?= or <? for portability reasons (and who knows, maybe it'd become deprecated one day). So, you're stuck with <?php echo and <?php.

    PHP Code:
    <?php foreach($users as $user): ?>
    <a href="/<?php echo htmlspecialchars($user?>">
      <?php echo htmlspecialchars($user)?>
    </a>
    <?php endforeach; ?>
    That's right. Ugly once again.

    Plus, that's a relatively simple block of code. Soon you have yourself <a href="<?php echo htmlspecialchars($user_id)?>"<?php if ($should_be_colored): ?> style="color: <?php echo htmlspecialchars($color)?>"<?php endif; ?>><?php if ($username): ?><?php echo htmlspecialchars($username)?><?php else: ?><em>(unknown)</em><?php endif; ?></a>

    If that were written in Smarty, it would be shorter and much easier to read. Plus, since Smarty's language doesn't make use of < and >, characters muddling themselves in (X)HTML look-alike syntax, it's even better.

    On top of all of this, if I want to add another escape function or so (such as one for JavaScript), I would have to muddle the global namespace with it*. One could put it in an object, but then you'd just make the template code even longer.

    *Though in PHP 5.3, functions are first class objects, but we're not there yet.

  8. #33
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
     
    foreach($users as $user) {
      echo 
    "<a href=\"/" htmlspecialchars($user) . "\">\r\n";
      echo 
    htmlspecialchars($user) . "\r\n";
      echo 
    "</a>\r\n";
     }
    //foreach
    ?>
    Looks fine to me :P

  9. #34
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's even worse. On any piece of complicated code, escaping becomes madness. If you use HEREDOC, then you can't put control statements anymore. Splitting the HEREDOC block into a bunch of smaller ones gets really bad, fast.

  10. #35
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    With syntax highlighting, it's easy. Are you really are using 'it makes the server side code look a bit nicer' as a reason to include a LOT of otherwise unnecessary bloat & complication, increased maintenance etc?

    I never use heredoc anyway, there is nothing wrong with the normal syntax.

    Oh, and I always hear 'polluting the global namespace' or whatever said, as though global functions are bad. What is so bad about them exactly? Global variables are bad because they are a nightmare to debug and trace. Functions are defined in one place and are pretty easy to trace, what is wrong with them?

  11. #36
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The bloat and complication is minimal, and the advantages are significant. Like I said in my first post: this is opinion, so don't think that your way is necessarily the "right" way. imaginethis, however, seems to think that his way is the only way.

  12. #37
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A valid use case for third-party template engine as opposed to native PHP templating is when you want to allow your user to upload their own templates to change the layout of the site. For the rest, native PHP templating should just be fine.

  13. #38
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sk89q View Post
    The bloat and complication is minimal, and the advantages are significant. Like I said in my first post: this is opinion, so don't think that your way is necessarily the "right" way. imaginethis, however, seems to think that his way is the only way.
    Did you read the post linked to earlier in the thread? It's an interesting read, and dispels the myth that a templating engine brings lots of advantages pretty well.

  14. #39
    SitePoint Addict
    Join Date
    Jun 2008
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stormrider View Post
    Did you read the post linked to earlier in the thread? It's an interesting read, and dispels the myth that a templating engine brings lots of advantages pretty well.
    If they don't give advantages, then why do so many people use them?

  15. #40
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by F.Danials View Post
    If they don't give advantages, then why do so many people use them?
    1. they don't realize that php is it's own template system
    2. They like the smarty lightbulb
    3. They want to try something new... before realizing that learning a new language is ridiculous when you already know php

  16. #41
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    someone for using templates post a bit of code using a template and i bet we php-is-a-template-system people can make it look just as "pretty" if not prettier than the template version

  17. #42
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I already posted a simple one, and it's not as pretty. No one has responded to my code, probably because there's no way to make it pretty (without making it non-portable).

    There are obviously advantages, otherwise no one would use them or switch to them. I used to use to mix PHP like that, but on more complicated pieces of code (such as repeating blocks of code [which requires putting code into a variable, which is very ugly] or dynamically toggling the existence of a CSS class or JavaScript snippet), the code gets horrific and line lengths become long (due to PHP's verbose syntax).

    Smarty compiles its templates to PHP, so the performance hit is minimal.

  18. #43
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well now youre just being silly. you posted one foreach loop, which in my eyes looks the same, but makes "more sense", than the smarty version(which i had to look up!) I didnt have to lookup the php version, i already knew it =)

  19. #44
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "Makes more sense" makes no sense. Bad argument. If I posted C# code, do I expect every PHP programmer to know C#? If it's Smarty, obviously you would have to know Smarty to understand it. Smarty has a very small learning curve though... I learned it in five minutes.

  20. #45
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "more sense" as in its the same basic way that other languages foreach's are constructed. I just looked at the smarty foreach an hour ago, and i already forgot =). i remember php's though

    my point is if you already know php, then there's no learning curve to use php as a template language, and no performance hit (even if it's a slight one).

  21. #46
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sk89q View Post
    I already posted a simple one, and it's not as pretty. No one has responded to my code, probably because there's no way to make it pretty (without making it non-portable).
    I just woke up...

    Quote Originally Posted by sk89q View Post
    You shouldn't depend on <?= or <? for portability reasons (and who knows, maybe it'd become deprecated one day). So, you're stuck with <?php echo and <?php.
    I've never worked on a server that didn't support <?= or <? and if I ever come across a server that doesn't then echo and print work just fine.

    Quote Originally Posted by sk89q View Post
    There are obviously advantages, otherwise no one would use them or switch to them.
    I think the anology -- If everyone jumped off a bridge would you? -- suffices.

    Quote Originally Posted by sk89q View Post
    I used to use to mix PHP like that, but on more complicated pieces of code (such as repeating blocks of code [which requires putting code into a variable, which is very ugly] or dynamically toggling the existence of a CSS class or JavaScript snippet), the code gets horrific and line lengths become long (due to PHP's verbose syntax).
    Go and look at X-Carts templates and tell me how much less complicated it is. If you can't read your code, then your probably doing something wrong.

    Quote Originally Posted by sk89q View Post
    Smarty compiles its templates to PHP, so the performance hit is minimal.
    Smarty is only efficient if its configured correctly and very few are.

    Quote Originally Posted by sk89q View Post
    No, it's an opinion. A templating engine would be "redundant" if it did not have advantages of its own. However, a good one does.
    See my quote above by Ramus... If he made it, I think he has a right to name it. As to your other point, Smarty's benefits, of which there are very few, are no more beneficial than the ones provided by a solid PHP framework.

    Smarty Code
    Code:
    {if $usertype eq "C"}
    {include file="customer/dialog.tpl"}
    {else}
    
    {if $printable ne ''}
    {include file="dialog_printable.tpl"}
    {else}
    <table cellspacing="0" {$extra}>
    <tr>
    <td class="DialogTitle">{$title}</td>
    </tr>
    <tr><td class="DialogBorder"><table cellspacing="1" class="DialogBox">
    <tr><td class="DialogBox" valign="{$valign|default:"top"}">{$content}
    &nbsp;
    </td></tr>
    </table></td></tr>
    </table>
    {/if}
    {/if}
    The PHP version
    PHP Code:
    <? if($usertype == 'c'): ?>
    <? 
    include 'customer/dialog.tpl' ?>
    <? 
    else ?>

    <? if($printable != ''): ?>
    <? 
    include 'dialog_printable.tpl' ?>
    <? 
    else ?>
    <table cellspacing="0" <?= $extra?>>
    <tr>
    <td class="DialogTitle"><?= $title?></td>
    </tr>
    <tr><td class="DialogBorder"><table cellspacing="1" class="DialogBox">
    <tr><td class="DialogBox" valign="<?= $valign ?>"><?= $content ?>
    &nbsp;
    </td></tr>
    </table></td></tr>
    </table>
    <? endif; ?>
    <? 
    endif; ?>
    Granted php doesn't have inline modifiers that work in the same way, but I don't think an inline modifier warrants it's use over PHP.

    Quote Originally Posted by sk89q View Post
    "Makes more sense" makes no sense. Bad argument. If I posted C# code, do I expect every PHP programmer to know C#?
    I would expect everyone to be able to understand C# code. The should at least be able to follow the logic. If there are comments, then they should have no problem being able to understand what it is you "mean" to say. If they can't understand simple logic, I wouldn't brand them a programmer >.>...

    Quote Originally Posted by sk89q View Post
    If it's Smarty, obviously you would have to know Smarty to understand it. Smarty has a very small learning curve though... I learned it in five minutes.
    Sure. Thats reasonable. However, if Smarty offers no intrinsic benefit I don't see the point in using it.
    Last edited by imaginethis; Dec 12, 2008 at 16:42. Reason: stupid typos >.<
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  22. #47
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginethis View Post
    I've never worked on a server that didn't support <?= or <? and if I ever come across a server that doesn't then echo and print work just fine.
    It's an option in php.ini that you can't depend on always being on.

    Quote Originally Posted by imaginethis View Post
    Smarty is only efficient if its configured correctly and very few are.
    I don't think you've ever even used Smarty, so I don't think you know what you are talking about, at all. You have to define a compile path for the templates, so you don't need to configure anything extra. The only extra flag you might want to configure is the one that toggles whether Smarty will check if it needs to recompile the templates, but this is absolutely so minor.

    It would be nice if you didn't pull your knowledge out of your end.

    Quote Originally Posted by imaginethis View Post
    See my quote above by Ramus... If he made it, I think he has a right to name it. As to your other point, Smarty's benefits, of which there are very few, are no more beneficial than the ones provided by a solid PHP framework.
    I never said that PHP wasn't a templating language. I know its history. It was a big hack that was used to create simple webpages.

    It's obvious that you don't know what a proper academic debate is. Do you not understand what 'opinion' is vs. 'fact'? "No more beneficial" is very much an opinion.

    Quote Originally Posted by imaginethis View Post
    Smarty Code
    Code:
    {if $usertype eq "C"}
    {include file="customer/dialog.tpl"}
    {else}
    
    {if $printable ne ''}
    {include file="dialog_printable.tpl"}
    {else}
    <table cellspacing="0" {$extra}>
    <tr>
    <td class="DialogTitle">{$title}</td>
    </tr>
    <tr><td class="DialogBorder"><table cellspacing="1" class="DialogBox">
    <tr><td class="DialogBox" valign="{$valign|default:"top"}">{$content}
    &nbsp;
    </td></tr>
    </table></td></tr>
    </table>
    {/if}
    {/if}
    The PHP version
    PHP Code:
    <? if($usertype == 'c'): ?>
    <? 
    include 'customer/dialog.tpl' ?>
    <? 
    else ?>

    <? if($printable != ''): ?>
    <? 
    include 'dialog_printable.tpl' ?>
    <? 
    else ?>
    <table cellspacing="0" <?= $extra?>>
    <tr>
    <td class="DialogTitle"><?= $title?></td>
    </tr>
    <tr><td class="DialogBorder"><table cellspacing="1" class="DialogBox">
    <tr><td class="DialogBox" valign="<?= $valign ?>"><?= $content ?>
    &nbsp;
    </td></tr>
    </table></td></tr>
    </table>
    <? endif; ?>
    <? 
    endif; ?>
    Granted php doesn't have inline modifiers that work in the same way, but I don't think an inline modifier warrants it's use over PHP.
    Yes, thank you for yet another code snippet. Unlike you, I actually know what I'm talking about because I have used both. As I've previously mentioned, a detailed PHP programmer going for portability would avoid using PHP's short tags. Thus, the code is much longer than that.

    Second, this part is not even making a statement, so I have nothing to reply to.

    Quote Originally Posted by imaginethis View Post
    I would expect everyone to be able to understand C# code. The should at least be able to follow the logic. If there are comments, then they should have no problem being able to understand what it is you "mean" to say. If they can't understand simple logic, I wouldn't brand them a programmer >.>...
    There will be many things in C# that someone that only knows PHP will be completely lost on.

    Quote Originally Posted by imaginethis View Post
    Sure. Thats reasonable. However, if Smarty offers no intrinsic benefit I don't see the point in using it.
    Opinion, opinion. Take a debate class.

    --

    Now, to this quote:

    Quote Originally Posted by imaginethis View Post
    I think the anology -- If everyone jumped off a bridge would you? -- suffices.
    Yes, it does. It applies to you, in fact. I have tried both Smarty and PHP for templates. Plus, I've made template engines on my own and used ones created by others. My opinion is my actual opinion.

    You have not used Smarty. From the looks of it, I assume you haven't even used a template engine. You are the sheep here "jumping off the bridge," because you've never tried it for yourself and you're just echoing what someone else you.

    This is my last post. This thread has become a stupid argument about opinion.

  23. #48
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    someones taking things personal =(

    I've used both. Ill never go back to using smarty. I just don't see any value in it.

  24. #49
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sk89q View Post
    It's an option in php.ini that you can't depend on always being on.
    I can always depend on it being on because I always have root access. I don't work on a server that I don't have root access on and I don't intend to.

    Quote Originally Posted by sk89q View Post
    I don't think you've ever even used Smarty, so I don't think you know what you are talking about, at all. You have to define a compile path for the templates, so you don't need to configure anything extra. The only extra flag you might want to configure is the one that toggles whether Smarty will check if it needs to recompile the templates, but this is absolutely so minor.
    I used smarty for 4 years and have developed many applications with it.

    Quote Originally Posted by sk89q View Post
    It would be nice if you didn't pull your knowledge out of your end.
    Sorry if I offended you? Calm yourself...


    Quote Originally Posted by sk89q View Post
    It's obvious that you don't know what a proper academic debate is.
    How is emotional outburst apart of a "proper academic debate" ...

    Quote Originally Posted by sk89q View Post
    Do you not understand what 'opinion' is vs. 'fact'? "No more beneficial" is very much an opinion.
    That was my own opinion... I never once implied that that statement was affect. The only fact I stated was the one by Ramus... He said it not me. Maybe direct your anger towards him >.>


    Quote Originally Posted by sk89q View Post
    Yes, thank you for yet another code snippet. Unlike you, I actually know what I'm talking about because I have used both. As I've previously mentioned, a detailed PHP programmer going for portability would avoid using PHP's short tags. Thus, the code is much longer than that.
    Again I used Smarty for 4 years. Lets leave our emotions out of this. Attack me personally is just childish -.-... If you are going to attack something, attack my logic attack my premise.... attack my argument...


    Quote Originally Posted by sk89q View Post
    There will be many things in C# that someone that only knows PHP will be completely lost on.
    Yes but the syntax is still similar enough that if its commented well enough that any programmer should be able to get the picture, however vague it might be.


    Quote Originally Posted by sk89q View Post
    Opinion, opinion. Take a debate class.
    ....


    Quote Originally Posted by sk89q View Post
    Yes, it does. It applies to you, in fact. I have tried both Smarty and PHP for templates. Plus, I've made template engines on my own and used ones created by others. My opinion is my actual opinion.
    And my opinions are not? I've used smarty... I've used others... And they are just semaphores ...

    Quote Originally Posted by sk89q View Post
    You have not used Smarty. From the looks of it, I assume you haven't even used a template engine. You are the sheep here "jumping off the bridge," because you've never tried it for yourself and you're just echoing what someone else you.
    ...


    Quote Originally Posted by sk89q View Post
    This is my last post. This thread has become a stupid argument about opinion.
    ...
    ...
    ...

    -.-
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  25. #50
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would be presumptuous to claim that Smarty is useless. Template engines like Smarty are definitely useful in certain cases. For example, if you want your site users to upload their own template there is no way you ever let them use PHP.

    For the rest of the cases, it’s matter of preference and opinion. Sure, if you like Smarty use it. If you think native templating is the way to go and smarty is not worth it, you are welcome to do so. On the other hand, if you keep ramming your opinions down others throat and claim to know one ‘true’ way of software engineering, you come off as rather immature. Someone who has just picked up a programming language and is so obsessed with it that he denies the existence of everything else.

    Take it easy! just move on..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •