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

Nodejs error handling process record

This article takes the connection error ECONNREFU...

Explanation of the steps for Tomcat to support https access

How to make tomcat support https access step: (1)...

Implementation code for using CSS text-emphasis to emphasize text

1. Introduction In the past, if you wanted to emp...

How to make an input text box change length according to its content

First: Copy code The code is as follows: <input...

mysql query data for today, this week, this month, and last month

today select * from table name where to_days(time...

Summary of methods to check whether the port is open in Linux

Method 1: Use lsof command We can use the lsof co...

Summary of MySQL's commonly used database and table sharding solutions

Table of contents 1. Database bottleneck 2. Sub-l...

MYSQL string forced conversion method example

Preface Since the types of the same fields in the...

WeChat Mini Program to Implement Electronic Signature

This article shares the specific code for impleme...

How to prevent Vue from flashing in small projects

Summary HTML: element plus v-cloak CSS: [v-cloak]...

border-radius method to add rounded borders to elements

border-radius:10px; /* All corners are rounded wi...

How to add website icon?

The first step is to prepare an icon making softwa...

An article to show you how to create and use Vue components

Table of contents 1. What is a component? 2. Crea...