回答編集履歴

2

検証追記

2018/12/29 07:48

投稿

can110
can110

スコア38266

test CHANGED
@@ -5,3 +5,79 @@
5
5
 
6
6
 
7
7
  [include](http://jinja.pocoo.org/docs/2.10/templates/#include)文自体には問題はないように見えます。
8
+
9
+
10
+
11
+ #### 検証
12
+
13
+ 以下コードにて、当方環境では構文エラー発生せず動作しました。
14
+
15
+ 提示コードでは`jinja2.exceptions.UndefinedError: 'dataset_count' is undefined`発生したため定義しています。
16
+
17
+ また、`index.html`では`{% include 'common/resource_info.html' %}`はコメントアウトしています。
18
+
19
+ `index_partial/datasets.html`は提示コードのままです。
20
+
21
+ ```Python
22
+
23
+ from flask import Flask, render_template
24
+
25
+
26
+
27
+ app = Flask(__name__)
28
+
29
+
30
+
31
+ def get_system_info():
32
+
33
+ return
34
+
35
+
36
+
37
+ @app.route('/')
38
+
39
+ def index():
40
+
41
+ return render_template("index.html", system_info=get_system_info(), dataset_count=0)
42
+
43
+
44
+
45
+ if __name__ == '__main__':
46
+
47
+ app.run(debug=True)
48
+
49
+ ```
50
+
51
+
52
+
53
+ ```Python
54
+
55
+ <!-- index.html -->
56
+
57
+ {% block page_content %}
58
+
59
+ <div class="container" id="main">
60
+
61
+ <div class="row">
62
+
63
+ <div class="col-md-9">
64
+
65
+ {% include 'index_partial/datasets.html' %}
66
+
67
+ </div>
68
+
69
+ <div class="col-md-3">
70
+
71
+ {# {% include 'common/resource_info.html' %} #}
72
+
73
+ </div>
74
+
75
+ </div>
76
+
77
+ </div>
78
+
79
+ {% endblock %}
80
+
81
+ ```
82
+
83
+ ![イメージ説明](2c599884b63a2c5c1e425cdd72202ce3.png)

1

追記

2018/12/29 07:47

投稿

can110
can110

スコア38266

test CHANGED
@@ -1,3 +1,7 @@
1
1
  `endfor`や`if`、`endif`の前後は`{{%`ではなく`{%`では?
2
2
 
3
3
  参考:[jinja2入門 その1](https://www.python.ambitious-engineer.com/archives/760)
4
+
5
+
6
+
7
+ [include](http://jinja.pocoo.org/docs/2.10/templates/#include)文自体には問題はないように見えます。