{"id":698,"date":"2026-10-14T10:03:20","date_gmt":"2026-10-14T01:03:20","guid":{"rendered":"https:\/\/www.marchboy.xyz\/wordpress\/archives\/698"},"modified":"2026-10-14T10:03:20","modified_gmt":"2026-10-14T01:03:20","slug":"jinja2%e3%83%86%e3%83%b3%e3%83%97%e3%83%ac%e3%83%bc%e3%83%88%e3%82%a8%e3%83%b3%e3%82%b8%e3%83%b3%e3%81%ae%e5%9f%ba%e7%a4%8e%e3%81%a8%e6%b4%bb%e7%94%a8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.marchboy.xyz\/wordpress\/archives\/698","title":{"rendered":"Jinja2\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u306e\u57fa\u790e\u3068\u6d3b\u7528\u65b9\u6cd5"},"content":{"rendered":"<h2>Jinja2\u3068\u306f<\/h2>\n<p>Jinja2\u306fPython\u5411\u3051\u306e\u9ad8\u6a5f\u80fd\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3067\u3059\u3002Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3084\u9759\u7684\u30b5\u30a4\u30c8\u306eHTML\u751f\u6210\u306b\u5e83\u304f\u5229\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u4e3b\u306a\u7279\u5fb4<\/h2>\n<ul>\n<li><strong>\u67d4\u8edf\u306a\u69cb\u6587<\/strong>\uff1aPython\u306b\u4f3c\u305f\u8868\u8a18\u3067\u6761\u4ef6\u5206\u5c90\u3084\u30eb\u30fc\u30d7\u304c\u66f8\u3051\u307e\u3059\u3002<\/li>\n<li><strong>\u7d99\u627f\u3068\u30d6\u30ed\u30c3\u30af<\/strong>\uff1a\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u5171\u901a\u5316\u3057\u3001\u90e8\u5206\u7684\u306b\u4e0a\u66f8\u304d\u53ef\u80fd\u3002<\/li>\n<li><strong>\u30d5\u30a3\u30eb\u30bf\u3068\u30c6\u30b9\u30c8<\/strong>\uff1a\u30c7\u30fc\u30bf\u5909\u63db\u3084\u691c\u8a3c\u3092\u7c21\u6f54\u306b\u8a18\u8ff0\u3002<\/li>\n<\/ul>\n<h2>\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h2>\n<h3>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4f5c\u6210<\/h3>\n<pre><code>{% raw %}{% extends \\\"base.html\\\" %}{% block content %}\n  <h1>{{ title }}<\/h1>\n  <ul>\n  {% for item in items %}\n    <li>{{ item }}<\/li>\n  {% endfor %}\n  <\/ul>\n{% endblock %}{% endraw %}<\/code><\/pre>\n<h3>Python\u304b\u3089\u306e\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0<\/h3>\n<pre><code>from jinja2 import Environment, FileSystemLoader\n\nenv = Environment(loader=FileSystemLoader(\\\"templates\\\"))\ntemplate = env.get_template(\\\"example.html\\\")\noutput = template.render(title='\u30b5\u30f3\u30d7\u30eb', items=['A', 'B', 'C'])\nprint(output)<\/code><\/pre>\n<h2>\u9ad8\u5ea6\u306a\u6a5f\u80fd<\/h2>\n<ul>\n<li>\u30ab\u30b9\u30bf\u30e0\u30d5\u30a3\u30eb\u30bf\u306e\u5b9a\u7fa9\n<ul>\n<li>\n<pre><code>def reverse_string(value):\n    return value[::-1]\n\nenv.filters['reverse'] = reverse_string<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u30de\u30af\u30ed\u306e\u5229\u7528\n<ul>\n<li>\n<pre><code>{% raw %}{% macro render_table(rows) %}\n<table>\n  {% for row in rows %}\n    <tr>{% for cell in row %}<td>{{ cell }}<\/td>{% endfor %}<\/tr>\n  {% endfor %}\n<\/table>\n{% endmacro %}{% endraw %}<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>Jinja2\u306f\u30b7\u30f3\u30d7\u30eb\u3055\u3068\u62e1\u5f35\u6027\u3092\u517c\u306d\u5099\u3048\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3067\u3059\u3002\u57fa\u672c\u69cb\u6587\u3092\u30de\u30b9\u30bf\u30fc\u3059\u308c\u3070\u3001Web\u958b\u767a\u306e\u751f\u7523\u6027\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jinja2\u3068\u306f Jinja2\u306fPython\u5411\u3051\u306e\u9ad8\u6a5f\u80fd\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30a8\u30f3\u30b8\u30f3\u3067\u3059\u3002Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3084\u9759\u7684\u30b5\u30a4\u30c8\u306eHTML\u751f\u6210\u306b\u5e83\u304f\u5229\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u4e3b\u306a\u7279\u5fb4 \u67d4\u8edf\u306a\u69cb\u6587\uff1aPython\u306b\u4f3c\u305f\u8868\u8a18\u3067\u6761\u4ef6\u5206\u5c90\u3084\u30eb\u30fc\u30d7\u304c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[],"class_list":["post-698","post","type-post","status-publish","format-standard","hentry","category-41"],"_links":{"self":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/698","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/comments?post=698"}],"version-history":[{"count":0,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/698\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/media?parent=698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/categories?post=698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/tags?post=698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}