简体   繁体   中英

How to comment on template files? (.tpl)

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?

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

{* INSERT COMMENT HERE *}

我的文件名是product_form.tpl它对我product_form.tpl

<!-- INSERT COMMENT HERE -->

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.

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.

唯一对我有用的是:

{%* INSERT COMMENT HERE *%}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM