This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template | |
app = Flask(__name__) | |
app.jinja_env.add_extension('jinja2.ext.loopcontrols') | |
@app.route('/', methods=['GET', 'POST']) | |
def index(): | |
return render_template('new.html', | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set users = ['Kaustubh', 'Saksham', 'Saumya', 'Ayushi', 'Abhishek', 'Anmol'] %} | |
{% import "helper.html" as helpers %} | |
{{helpers.generateList(users)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro generateList(input_list)%} | |
<ul> | |
{% for i in input_list %} | |
<li>{{i}}</li> | |
{% endfor %} | |
</ul> | |
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set links %} | |
<li><a href="/">Index</a> | |
<li><a href="/blogs">Blogs</a> | |
<li><a href="/about">About</a> | |
<li><a href="/work">Work</a> | |
{% endset %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set users = ['Kaustubh', 'Saksham', 'Saumya', 'Ayushi', 'Abhishek', 'Anmol'] %} | |
{% macro generateList(input_list)%} | |
<ul> | |
{% for i in input_list %} | |
<li>{{i}}</li> | |
{% endfor %} | |
</ul> | |
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% block title %}This is the child page{% endblock %} | |
{% block content %} | |
<h1>This is the child page</h1> | |
<p class="important"> | |
The content here is from the child template | |
</p> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>{% block title %}{% endblock %} - My Webpage</title> | |
</head> | |
<body> | |
<h3>This will come up in every Webpage (Base template)</h3> | |
<div id="content">{% block content %}{% endblock %}</div> | |
<div id="footer"> | |
This content is from base template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro generateList(input_list)%} | |
<ul> | |
{% for i in input_list %} | |
<li>{{i}}</li> | |
{% endfor %} | |
</ul> | |
{% endmacro %} | |
{{generateList(users)}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for i in <iterable_object> %} | |
{% if <condition> %} | |
{# the if part #} | |
{% elif <condition> %} | |
{# the elif part #} | |
{% else %} | |
{# the else part #} | |
{% endif %} | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for i in <iteratable_object> %} | |
{# operations to perform #} | |
{% endfor %} |
NewerOlder