inertia

Types

Values

pub fn add_context(name: String, value: String) -> Nil

Add an entry to the inertia context

pub fn add_defer(
  self: props.PageObject,
  name: String,
  value: fn() -> Result(json.Json, Nil),
  group: option.Option(String),
) -> props.PageObject

Adds a deferred property. Usually, a deferred property is a time-consuming function that will take time to generate its outcome. The property value is a function that returns Result(json.Json, Nil)

pub fn add_error(
  self: props.PageObject,
  name: String,
  value: json.Json,
) -> props.PageObject

Adds an error property. The value must be a json.Json value

pub fn add_once(
  self: props.PageObject,
  name: String,
  value: fn() -> json.Json,
) -> props.PageObject

Adds an once property. The property value must be a function that returns a json.Json value.

pub fn add_prop(
  self: props.PageObject,
  name: String,
  value: json.Json,
) -> props.PageObject

Adds a basic property to be injected on the client. The value must be a json.Json value

pub fn from_context(name: String) -> String

Gets an entry from the inertia context, if it not exists returns an empty String

pub fn handle_request(
  req: request.Request(wisp.Connection),
  next: fn(request.Request(wisp.Connection)) -> response.Response(
    wisp.Body,
  ),
) -> response.Response(wisp.Body)

Handle request middleware that manages all Inertia requests

pub fn init(app: String, version: String) -> Nil

Initializes the inertia context

pub fn new_page_object(
  req: request.Request(wisp.Connection),
  component: String,
) -> props.PageObject

Creates a page object that will manage all properties for the current page component.

pub fn redirect(
  req: request.Request(wisp.Connection),
  path: String,
) -> response.Response(wisp.Body)

Creates a reponse with status code 303 for Post, Patch, Put or Delete request, otherwise the status code is 302

#Example

inertia.redirect(req, "/")
pub fn render(
  page_object: props.PageObject,
  req: request.Request(wisp.Connection),
) -> response.Response(wisp.Body)

Renders a Inertia component based on the PageObject.

#Example:

inertia.new_page_object(req, "index)
|> inertia.render(req)
pub fn root_view(state: String) -> String

Creates the root view based on index.html file when the request is a full page load. If the index.html file is not found, it will render a default error message

Search Document