Plain is headed towards 1.0! Subscribe for development updates →

 1from __future__ import annotations
 2
 3from typing import Any
 4
 5from plain.assets.finders import APP_ASSETS_DIR
 6from plain.internal import internalcode
 7from plain.runtime import settings
 8from plain.templates import register_template_extension
 9from plain.templates.jinja.extensions import InclusionTagExtension
10
11
12@internalcode
13@register_template_extension
14class TailwindCSSExtension(InclusionTagExtension):
15    tags = {"tailwind_css"}
16    template_name = "tailwind/css.html"
17
18    def get_context(
19        self, context: dict[str, Any], *args: Any, **kwargs: Any
20    ) -> dict[str, str]:
21        tailwind_css_path = str(settings.TAILWIND_DIST_PATH.relative_to(APP_ASSETS_DIR))
22        return {"tailwind_css_path": tailwind_css_path}