How can I insert HTML comments?

This is a very simple question, but it annoyed me. I would like to comment on the following examples:

<!-- {if $scenes} <!-- Scenes --> {include file="$tpl_dir./scenes.tpl" scenes=$scenes} {else} <!-- Category image --> {if $category->id_image} <div class="align_center"> <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" /> </div> {/if} {/if} --> 

I would like to comment on all this text, so the browser did not win, t will display this code. The problem is that I already have comments, and the browser seems to be confused by the end tag. Therefore, in this case, only the first opening comment comment tag will affect {if $ scenes} if I want this to affect the entire text. Could you tell me how this can be done?!?!

Thanks,

Dani

+4
source share
2 answers

If I understand you correctly, you want you to be able to embed your HTML comments. To do this, you need to replace the double dash with two single strokes and a space - - .

Basically,

 <!-- This is a comment. <!- - This is a nested comment. - -> --> 

When applying this to your code, you should get something like this:

 <!-- {if $scenes} <!- - Scenes - -> {include file="$tpl_dir./scenes.tpl" scenes=$scenes} {else} <!- - Category image - -> {if $category->id_image} <div class="align_center"> <img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" /> </div> {/if} {/if} --> 
+3
source

The language you have is not HTML, but the language that generates HTML. The language obviously supports if / else clauses that nest, since you are showing a very example of this. Thus, even if the language generating the HTML code itself does not have nesting comments, you can use conditional expressions to remove parts of it due to its execution, therefore suppressing the generation of this HTML code:

Suppose that the false token is the logical value false (replace the correct expression for false in the given template language):

 {if false} {if $scenes} <!-- ... > {else} ... {/if} {/if} 

Everything in the if false block is excluded from the output by the processor.

+1
source

All Articles