"""Jinja2-based attribute templating with ``..`` / ``...`` parent access. Syntax inside ``{{ }}`` expressions: - ``..`` → immediate parent (alias ``p1``) - ``...`` → parent of parent (alias ``p2``) - ``....`` → great-grandparent (alias ``p3``) - ``service`` → the Service instance - ``index`` → 0-based index within a ``quantity`` loop Example:: attrs: name: "rtr-{{ service.tenant.slug }}-{{ index + 1 }}" site: "{{ ..site.pk }}" # parent device's site PK notes: "{{ ...region.slug }}" # grandparent region slug """ import re from jinja2.sandbox import SandboxedEnvironment _DOT_RE = re.compile(r"(?