LoginSignup
0
0

More than 5 years have passed since last update.

FLASK  共通テンプレートの作り方【Windows.ver】

Last updated at Posted at 2019-06-22

共通テンプレートの作り方

  1. templetes フォルダにindex.htmlの内容をコピーして新しいファイルlayout.htmlを作成

※index.htmlの内容とは
2019-06-22 (3).png

このコードを編集してlayout.htmlに共通テンプレートを作っていきましょう!

2019-06-22 (8).png

<body></body>の中に
<P>共通テンプレート</p>
{% block content %}
{% endblock %}

次にindex.htmlを開いて
2019-06-22 (11).png

<head><head/>のヘッダーの中身を削除
{% extends "layout.html" %}で共通テンプレートのlayout.htmlをよびだす
{% block content %}と記載。これより先のコードを
layout.htmlの{% block content %}の部分に埋め込むイメージ

コードの末は
{% endblock %}

ブラウザで表示すると

共通テンプレートと表示される
埋め込んだコードの文章が表示される
2019-06-22 (12).png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0