diff --git a/README.md b/README.md index 4f8d650..ce914e1 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,15 @@ You can find the legacy Inertia PingCRM demo with Masonite here [demo](https://g ## Features -- _Add your package main features here_ -- _and here_ +Almost all features of the official server-side adapters are present 😃 + +- Shared data +- Partial reloads +- Lazy loaded props +- Set root view in a provider +- Set root view per view +- Enable sharing Masonite routes (prefer using [masonite-js-routes](https://github.com/girardinsamuel/masonite-js-routes)) +- Enable sharing Masonite flash messages ## Official Masonite Documentation diff --git a/app/http/controllers/InertiaController.py b/app/http/controllers/InertiaController.py index 9cf9618..5282ef1 100644 --- a/app/http/controllers/InertiaController.py +++ b/app/http/controllers/InertiaController.py @@ -1,9 +1,10 @@ """Inertia Demo Controller""" from masonite.controllers import Controller -from masonite.inertia import InertiaResponse from masonite.view import View from masonite.request import Request +from masonite.inertia import InertiaResponse + class InertiaController(Controller): """Controller for testing Inertia.""" @@ -22,6 +23,4 @@ def inertia_with_error(self, view: InertiaResponse, request: Request): return request.redirect("/") def helloworld(self, view: InertiaResponse): - return view.render("HelloWorld", {"first_name": "Sam"}).with_root_view( - "spa_view_2" - ) + return view.render("HelloWorld", {"first_name": "Sam"}, "spa_view_2") diff --git a/config/inertia.py b/config/inertia.py index d402572..e679dfa 100644 --- a/config/inertia.py +++ b/config/inertia.py @@ -6,8 +6,52 @@ | Mix Manifest |-------------------------------------------------------------------------- | -| Absolute path to mix-manifest.json location +| Absolute path to mix-manifest.json location. It's needed for computing +| js assets version. | +| default: root directory """ PUBLIC_PATH = os.getcwd() + + +""" +|-------------------------------------------------------------------------- +| Root view +|-------------------------------------------------------------------------- +| +| Root template view used by your Inertia Controllers to render the page. +| This is the name of the view without .html. This can also be overriden with +| set_root_view Inertia helper. +| +| default: app +""" + +ROOT_VIEW = "spa_view" + +""" +|-------------------------------------------------------------------------- +| Include routes +|-------------------------------------------------------------------------- +| +| Include server-side routes as JSON payload in Inertia response (props) +| Might be needed if you're not using masonite-js-routes. You can also do +| it yourself with Inertia share helper. +| +| default: False +""" + +INCLUDE_ROUTES = False + +""" +|-------------------------------------------------------------------------- +| Share flash message +|-------------------------------------------------------------------------- +| +| Include flash messages as JSON payload in Inertia response (props) +| You can also do it yourself with Inertia share helper. +| +| default: True +""" + +INCLUDE_FLASH_MESSAGES = True diff --git a/resources/templates/spa_view_2.html b/resources/templates/spa_view_2.html index b3400ff..32815da 100644 --- a/resources/templates/spa_view_2.html +++ b/resources/templates/spa_view_2.html @@ -6,7 +6,6 @@
Current route: {{ route().current() }}