Do any of you use a templating engine?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jmDesktop

    Do any of you use a templating engine?

    Hi, I was using .net and it uses templates. I like that it did not
    mix the UI with logic. I saw there are many templating engines for
    php usage. Can you recommend one? I don' t know which to pursue. I
    don't need MVC at the moment, but I don't know that the templating
    engines require it either.

    Thank you.
  • AqD

    #2
    Re: Do any of you use a templating engine?

    On Sep 9, 10:28 am, jmDesktop <needin4mat...@ gmail.comwrote:
    Hi, I was using .net and it uses templates.  I like that it did not
    mix the UI with logic.  I saw there are many templating engines for
    php usage.  Can you recommend one?  I don' t know which to pursue.  I
    don't need MVC at the moment, but I don't know that the templating
    engines require it either.
    >
    Thank you.
    Templating engine isn't needed for MVC. I can't recommand you any pure
    templating engines since all PHP ones I know lack simple custom tags
    (usually another html file containing place-holders), and their
    template syntax(s) don't look any more elegant than php+html.

    If you want MVC, try frameworks like symfony or PRADO. Those
    frameworks usually come with some sort of templating engines.

    Comment

    • Sjoerd

      #3
      Re: Do any of you use a templating engine?

      On Mon, 08 Sep 2008 19:28:29 -0700, jmDesktop wrote:
      Hi, I was using .net and it uses templates. I like that it did not mix
      the UI with logic. I saw there are many templating engines for php
      usage. Can you recommend one? I don' t know which to pursue. I don't
      need MVC at the moment, but I don't know that the templating engines
      require it either.
      Smarty is by far the best known PHP template engine. However, in my
      experience using template engines is cumbersome, inflexible, slow running
      and slow to develop. Your templates and your code end up being closely
      related anyway and you type your templates in a strange language when PHP
      could have done just the same.

      Comment

      • Norman Peelman

        #4
        Re: Do any of you use a templating engine?

        jmDesktop wrote:
        Hi, I was using .net and it uses templates. I like that it did not
        mix the UI with logic. I saw there are many templating engines for
        php usage. Can you recommend one? I don' t know which to pursue. I
        don't need MVC at the moment, but I don't know that the templating
        engines require it either.
        >
        Thank you.
        PHP is the perfect programming language for web application backends. Use Astec's top PHP development services to create your web application.


        That's the one I use... simple and blazingly fast. I'm using the old
        one not the new one (yet).

        --
        Norman
        Registered Linux user #461062
        -Have you been to www.php.net yet?-

        Comment

        • Jeff

          #5
          Re: Do any of you use a templating engine?

          jmDesktop wrote:
          Hi, I was using .net and it uses templates. I like that it did not
          mix the UI with logic. I saw there are many templating engines for
          php usage. Can you recommend one? I don' t know which to pursue. I
          don't need MVC at the moment, but I don't know that the templating
          engines require it either.
          I've always rolled own out of a couple of regexes.

          The tags are just name/value pairs and I make an associative array
          ($EDIT_TAG) out of them.

          If I find a match for something in the library I return the code for
          that match, otherwise I do this:

          global $CUSTOM;
          if((isset($EDIT _TAG['mode']))&&($EDIT_TAG['mode']=='custom')){
          if(function_exi sts($CUSTOM[$EDIT_TAG['name']])){
          return $CUSTOM[$EDIT_TAG['name']]($this,$EDIT_TA G);
          }
          }

          I'm a relative newcomer to php, so that's not the best coding.

          That's completely flexible. I can read instructions from the tag,
          read instructions from the query string, if it's in my CMS, I have the
          page path in $this. I can print static pages (which I do for the CMS) or
          just spit it back out. I can mix CMS and database output.

          I suppose if I had ever gotten through reading someone elses template
          engine, I'd use that. But this makes it easy for me to use the same
          template for all my needs. If the design changes, I only need to change
          the template.

          Jeff
          >
          Thank you.

          Comment

          • Egbert Teeselink

            #6
            Re: Do any of you use a templating engine?

            On Sep 9, 4:28 am, jmDesktop <needin4mat...@ gmail.comwrote:
            Hi, I was using .net and it uses templates.  I like that it did not
            mix the UI with logic.  I saw there are many templating engines for
            php usage.  Can you recommend one?  I don' t know which to pursue.  I
            don't need MVC at the moment, but I don't know that the templating
            engines require it either.
            >
            Thank you.
            I'm pretty fond of template engines, because even though PHP is one
            itself, I hate the syntax of it, especially when you do a lot of
            little things throughout a view; nested loops, escaping values,
            etcetera quickly make the code a mess.

            I used smarty a lot, but it has as many drawbacks as advantages. I
            ended up coding my own: http://e.teeselink.nl/mplate - it's a bit like
            smarty, but simpler, and most notably allows PHP syntax for function
            calls. As such, there's no need to learn yet another new language.
            Additionally, there's no real implementation overhead; it's designed
            to be nothing but a template engine (= syntactical sugar for your
            views) and nothing else, and aims to be easy to plug in to your
            current framework/setup/whatever.

            </shameless_plug>

            Egbert

            Comment

            Working...