From 42ac5217fe83f13635c92eca1641c4c8beb843d8 Mon Sep 17 00:00:00 2001 From: Scoder12 <34356756+Scoder12@users.noreply.github.com> Date: Tue, 11 Aug 2020 14:38:57 -0700 Subject: [PATCH] Add init method and nice_jinja setting --- src/replit/maqpy/app.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/replit/maqpy/app.py b/src/replit/maqpy/app.py index de7b7e5..0bc3b1e 100644 --- a/src/replit/maqpy/app.py +++ b/src/replit/maqpy/app.py @@ -75,7 +75,24 @@ class App(flask.Flask): request_class = Request - def login_wall(self, exclude: Set[str] = ("/",), handler: Callable = None) -> None: + def __init__( + self, import_name: str, nice_jinja: bool = True, **kwargs: Any + ) -> None: + """Initialize the app. + + Args: + import_name (str): The name of the app, usually __name__ + nice_jinja (bool): Whether to change jinja settings to make them + prettier. Defaults to True. + **kwargs (Any): Extra keyword arguments to be passed to the flask init + function. + """ + super().__init__(import_name, **kwargs) + if nice_jinja: + self.jinja_env.trim_blocks = True + self.jinja_env.lstrip_blocks = True + + def login_wall(self, exclude: Set[str] = ("/",), handler: Callable = None,) -> None: """Require users to be logged-in on all pages. Args: