-
前提 Python: 3.12 参考 リスト型 (list) — 組み込み型 — Python 3.12.3 ドキュメント 初期化 l = ['aaa', 'bbb'] 要素を追加する リストの最後に要素を追加する l = ['aaa', 'bbb'] l.append('ccc') print(l) 実行結果 ['aaa', 'bbb', 'ccc'] 指定し
-
前提 Python: 3.12 参考 マッピング型 — dict — 組み込み型 — Python 3.12.3 ドキュメント 初期化 d = {'aaa': 1, 'bbb': 2} キーが存在するか確認する d = {'aaa': 1, 'bbb': 2} if 'aaa' in d.keys(): 処理 値を取得する d =
-
前提 Python: 3.12 基本 for i in range(5): print(i) else: 処理 for i in range(-5, 2): print(i) for i in range(5): if i == 2: continue if i == 3: break print(i) 参考 8.3. for 文 — 8. 複合文 (compound statement) — Python 3.12.3 ドキュメント else else節がある場合、ルー
-
前提 Python: 3.12 基本 if 条件式: 処理 elif 条件式: 処理 else: 処理 if not 条件式: 処理 参考 8.1. if 文 — 8. 複合文 (compound statement) — Python 3.12.3 ドキュメント 変数がNoneか判定する Noneかど
-
前提 Python: 3.12 Jinja2: 3.1.3 継承 継承するとベースとなるテンプレート(base.html)の{% block %} {% endblock %}タグで囲っている箇所だけ変更できる。 継承するテンプ
-
前提 Python: 3.12 Jinja2: 3.1.3 テンプレートにパラメータを渡す tpl = env.get_template('template.tpl') params = { 'navigation': [ { 'href': 'https://example.com/', 'text': 'Home' }, { 'href': 'https://example.com/about/', 'text': 'About' } ] } tpl.render(params) 上記のようなパラメータを渡した場合、テンプレートでは
-
前提 Python: 3.12 Jinja2: 3.1.3 Install pip install Jinja2 Sample from jinja2 import Environment, FileSystemLoader loader = FileSystemLoader(template_dir, encoding='utf-8') env = Environment(Loader=loader, autoescape=False) tpl = env.get_template(template_name) params = { 'title': 'Example Page Title' } with open(path, mode='w', encoding='utf-8') as f: f.write(tpl.render(params)) 変数 テンプレート内での使用 <h1>{{ title }}</h1> for文の中で使用できる
-
前提 Windows インストール 以下のサイトからインストーラーをダウンロードしてインストールするか、scoopを使用してインストールする。 https://www.python.org/downloads/windows/ scoop install python IDE(
-
前提 Hugo: v0.125.4 注意事項 この記事内で紹介しているShortcodeをそのまま使用すると、使用箇所によってはタイムアウトとなりうまく機能しない。 【Hu
-
前提 Hugo: v0.125.4 TableOfContents 以下のメソッドを呼ぶだけで目次が作れる {{ .TableOfContents }} このページの場合、以下のhtmlが出力される <nav id="TableOfContents"> <ul> <li><a href="#前提"
-
前提 Hugo: v0.125.4 対応内容 MarkdownをShortcode内に記載したときに、期待した結果が得られないことがあったので整理。 対応する方法としては、
-
Stylelint バージョン 16.4.0 インストール npm install --save-dev stylelint stylelint-config-standard-scss stylelint-config-recess-order 設定ファイル .stylelintrc.yaml extends: - stylelint-config-standard-scss - stylelint-config-recess-order - stylelint-prettier/recommended rules: block-no-empty: true no-duplicate-selectors: null Prettier バージョン 3.2.5 インストール npm install --save-dev prettier stylelint-prettier 設定ファイル .prettierrc.yaml tabWidth: 4 Style
-
前提 環境: Windows Hugo: v0.125.4 Dart Sassのインストール Hugo ExtendedにはLibSassが含まれているが、非推奨となっているため、Dart Sassをイン
-
前提 Hugo: v0.125.4 変数 定義 {{ $foo := "foo" }} 代入 {{ $foo = "bar" }} テンプレート内での使用 <p>{{ $foo }}</p> 比較 Eq arg1 == arg2 {{ eq 1 1 }} # true {{ eq 1 2 }} # false {{ eq "foo" "foo" }} # true {{ eq "foo" "bar" }} # false 参考
-
前提 環境: Windows Hugo: v0.125.4 インストール バイナリをダウンロードして配置 Githubからバイナリをダウンロード Releases latest ダウンロードしたファイルを解凍し、任意の
-