Template

モジュール概要

Filesystem template loader.

チュートリアル

最初に以下の最小例でモジュール利用方法を確認し、その後 API リファレンスを参照してください。

from nexom.app.template import ObjectHTMLTemplates

templates = ObjectHTMLTemplates(base_dir='templates', reload=False)
html = templates.render('default', title='Nexom')

運用チェックリスト

  • 本番では例外処理を必ず実装し、戻り値の型を固定してください。
  • 引数のデフォルト値と必須/任意を仕様書としてチーム内で固定してください。
  • ログと監視を追加し、エラー時の復旧手順を運用Runbookに記載してください。

API リファレンス(全関数・全メソッド)

クラス

TemplateEntry

分類: public class

クラスドキュメントは未定義です。

このクラスにメソッド定義はありません。

_TemplateAccessor

分類: internal class

Callable attribute-chain proxy. Examples: templates.default(title="x") -> templates.render("default", title="x") templates.layout.base(title="x") -> templates.render("layout.base", title="x")

_TemplateAccessor の全メソッド

__init__

分類: special method

シグネチャ
__init__(self, templates: 'ObjectHTMLTemplates', name: str) -> None
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • templates / kind=positional-or-keyword / type='ObjectHTMLTemplates' / 必須 / default=なし
  • name / kind=positional-or-keyword / type=str / 必須 / default=なし
戻り値

None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import _TemplateAccessor

obj = _TemplateAccessor(templates=..., name="sample")
__getattr__

分類: special method

シグネチャ
__getattr__(self, part: str) -> '_TemplateAccessor'
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • part / kind=positional-or-keyword / type=str / 必須 / default=なし
戻り値

'_TemplateAccessor'

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import _TemplateAccessor

obj = _TemplateAccessor(...)
result = obj.__getattr__(part="sample")
print(result)
__call__

分類: special method

シグネチャ
__call__(self, **kwargs: str) -> str
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • kwargs / kind=variadic-keyword(**kwargs) / type=str / 必須 / default=なし
戻り値

str

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import _TemplateAccessor

obj = _TemplateAccessor(...)
result = obj.__call__()
print(result)
__repr__

分類: special method

シグネチャ
__repr__(self) -> str
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • 引数なし
戻り値

str

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import _TemplateAccessor

obj = _TemplateAccessor(...)
result = obj.__repr__()
print(result)

ObjectHTMLTemplates

分類: public class

Loads all *.html templates under base_dir and renders them using ObjectHTML. Public API: render("a.b", **kwargs) -> str Sugar: templates.a.b(**kwargs) -> render("a.b", **kwargs)

ObjectHTMLTemplates の全メソッド

__init__

分類: special method

シグネチャ
__init__(self, base_dir: str, reload: bool = False) -> None
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • base_dir / kind=positional-or-keyword / type=str / 必須 / default=なし
  • reload / kind=positional-or-keyword / type=bool / 任意 / default=False
戻り値

None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import ObjectHTMLTemplates

obj = ObjectHTMLTemplates(base_dir="sample", reload=False)
__getattr__

分類: special method

シグネチャ
__getattr__(self, name: str) -> _TemplateAccessor
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • name / kind=positional-or-keyword / type=str / 必須 / default=なし
戻り値

_TemplateAccessor

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import ObjectHTMLTemplates

obj = ObjectHTMLTemplates(...)
result = obj.__getattr__(name="sample")
print(result)
render

分類: public method

シグネチャ
render(self, name: str, **kwargs: str) -> str
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • name / kind=positional-or-keyword / type=str / 必須 / default=なし
  • kwargs / kind=variadic-keyword(**kwargs) / type=str / 必須 / default=なし
戻り値

str

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import ObjectHTMLTemplates

obj = ObjectHTMLTemplates(...)
result = obj.render(name="sample")
print(result)
_rebuild_engine

分類: internal method

シグネチャ
_rebuild_engine(self) -> None
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • 引数なし
戻り値

None

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import ObjectHTMLTemplates

obj = ObjectHTMLTemplates(...)
result = obj._rebuild_engine()
print(result)
_scan_templates

分類: internal method

シグネチャ
_scan_templates(self, root: Path) -> list[TemplateEntry]
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • root / kind=positional-or-keyword / type=Path / 必須 / default=なし
戻り値

list[TemplateEntry]

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import ObjectHTMLTemplates

obj = ObjectHTMLTemplates(...)
result = obj._scan_templates(root="/path/to/value")
print(result)
_path_to_template_name

分類: internal method

シグネチャ
_path_to_template_name(self, rel_path: Path) -> str
使い方と仕様

メソッドドキュメントは未定義です。

引数
  • rel_path / kind=positional-or-keyword / type=Path / 必須 / default=なし
戻り値

str

例外・注意点

実装コード内の例外仕様を確認してください。

利用例
from nexom.app.template import ObjectHTMLTemplates

obj = ObjectHTMLTemplates(...)
result = obj._path_to_template_name(rel_path="/path/to/value")
print(result)

ソース情報

  • module: nexom.app.template
  • source file: services/venv/lib/python3.10/site-packages/nexom/app/template.py
  • generated date: 2026-03-14