Create condition in Html file?

Hey on my project I would like to create condition in to my html generator template.

Like this example :

{ #if test }
   <h2>Ceci est le titre : {test}</h2>
{ /if }

I saw we can use {{ $if() }} but I don’t think I can’t use it to add html code if the variable exists on my input json

If you have another clean methods, I’m interested ^^

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

either that, or you create a variable beforehand that is either "" or

" ```
<h2>Ceci est le titre : {test}</h2>
```"

and add the variable to the html

Hey, I’m not sure to understand :confused:

We do not have a template language like that, but you can solve it with expressions. Here’s one approach:

Here’s a small workflow to test this with. If you disable the ‘Set Title’ node, the <h2> node won’t show. For more complex situations, you’d probably want to use a code node and solve all this in Javascript.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.