Usage of if judgment in HTML

Usage of if judgment in HTML

In the process of Django web development, when writing HTML, a list variable with the same name is passed from the backend, but the content format is different and needs to be judged separately. I have consulted many articles and tried several methods, but the format seems to be wrong (I have not systematically studied the front end, and basically just copied it)
Later I found the usage of html if in Django framework

The format is roughly as follows

  <div class="if/else">
                    {% if formname == 'Callrecords' %}
                        Callrecords
                    {% elif formname == 'Riderecords' %}
                        Riderecords
                    {% elif formname == 'Clubinfo' %}
                        Clubinfo
                    {% elif formname == 'Clubmemb' %}
                        Clubmemb
                    {% elif formname == 'Personinfo' %}
                        Personinfo
                    {% endif %}
                    </div>

This syntax is provided by Django and is used in native HTML code writing but is useless. The code box above uses the HTML format, but you can also see that the content between the <div> tags cannot be marked by the HTML language, indicating that it is not a built-in HTML syntax.
But at least my Django project has no problem using it!

Summarize

The above is the usage of if judgment in HTML introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time!

<<:  How to check if data exists before inserting in mysql

>>:  Detailed explanation of the principle of Vue monitoring data

Recommend

How to set PATH environment variable in Linux system (3 methods)

1. In Windows system, many software installations...

A complete tutorial on using axios encapsulation in vue

Preface Nowadays, in projects, the Axios library ...

How to reduce the memory and CPU usage of web pages

<br />Some web pages may not look large but ...

How to build a Vue3 desktop application

In this article, we will look at how to develop a...

How to embed other web pages in a web page using iframe

How to use iframe: Copy code The code is as follo...

Related operations of adding and deleting indexes in mysql

Table of contents 1. The role of index 2. Creatin...

Solution to the docker command exception "permission denied"

In Linux system, newly install docker and enter t...

Detailed method of using goaccess to analyze nginx logs

Recently I want to use goaccess to analyze nginx ...

A detailed discussion of components in Vue

Table of contents 1. Component Registration 2. Us...

Docker-compose tutorial installation and quick start

Table of contents 1. Introduction to Compose 2. C...

Example code of vue custom component to implement v-model two-way binding data

In the project, you will encounter custom public ...

Vue realizes the function of uploading photos on PC

This article example shares the specific code of ...

Solution to SNMP4J server connection timeout problem

Our network management center serves as the manag...