How to comment on template files? (.tpl)

43,991

Solution 1

Solved! To comment on such files...I should use

{* INSERT COMMENT HERE *}

Solution 2

My file name is product_form.tpl It works to me.

<!-- INSERT COMMENT HERE -->

Solution 3

I think that the approved answer is correct only in that specific case. For example, in OVOLogistics PDF Generator for CS-CART all the following comments types don't work.

<!-- INSERT COMMENT HERE -->
{%* INSERT COMMENT HERE *%}
{* INSERT COMMENT HERE *}

As igronus said

It totally depends on template engine you are using. Some of them have no comment feature at all. You should carefully read documentation or browse source code if possible.

Solution 4

It totally depends on template engine you are using. Some of them have no comment feature at all. You should carefully read documentation or browse source code if possible.

On my previous job I had to deal with really obsolete code from 90s with few internal-written template engines and at least in one of them I didn't find any comment feature after reading internal documentation. After browsing the code I realised that the template logic flow was based on top of few preg_replace calls with no comment feature implementation at all.

Share:
43,991
Woppi
Author by

Woppi

Updated on December 31, 2020

Comments

  • Woppi
    Woppi over 3 years

    I am trying to do some commenting on a .html.tpl file I'm maintaining using

    <!-- -->
    

    but it would return syntax error.

    How do you put comment on such files?

  • Don McCurdy
    Don McCurdy over 10 years
    Are you using some particular templating library? This doesn't appear to do anything in pure PHP, for me.
  • Woppi
    Woppi over 2 years
    @DonMcCurdy Sorry, just saw your comment after 7 years. I used to maintain a project using "Smarty template engine" back in the day. :)