CRM-8960 Support alternative template engines

    Details

    • Type: New Feature
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 4.1.0
    • Fix Version/s: 4.4.0
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      Patch is a proof-of-concept, template files can be written in any templating language. The Smarty "include" tag is compiled to use this generic loader, so any template in the hierarchy can be replaced.

      Including smarty again from your custom templates isn't implemented, so you'll have to do that manually.

      Templates are autodiscovered using the current php include path, and the civi templates_dir array. File type is determined by its extension, so adding new template engines should just be a matter of declaring the new type in config->templateExtensions, and writing a small glue class in CRM/Core/Template/

      Note: The Twig engine depends on having that library installed, the default location is packages/symfony/vendor/twig, but you can reconfigure by declaring $config->twigDir

      See the branch https://fisheye2.atlassian.com/changelog/~br=adamw-alternative_template_engines/CiviCRM

        Attachments

          Activity

          [CRM-8960] Support alternative template engines
          Adam Wight added a comment -

          Improved patch can load PHP and correctly passes local variable context to template render

          Adam Wight added a comment -

          Mustache support. No idea if partials will work.

          The major flaw with my approach so far is that string templates (from the database) are only rendered by Smarty. In order to choose an alternative template engine, we would have to associate type information.

          https://svn.civicrm.org/civicrm/branches/adamw-alternative_template_engines

          Adam Wight added a comment -

          Mustache partials do work, but must be specified using the path relative to templates/ and the extension, e.g. > CRM/Event/Cart/Page/part.ms

          Another issue is that the mustache.php library is not designed to search multiple template directories, so we make an arbitrary choice to only look in the first directory of CRM_Core_Config -> templateDir.

          Donald A. Lobo added a comment -


          Closing issues in batch on 4/16/13 since these issues have not been worked on in a long long time

            People

            • Assignee:
              Adam Wight
              Reporter:
              Adam Wight

              Dates

              • Created:
                Updated:
                Resolved: