OctaStar.Scripts (octa_star v0.2.0)

Copy Markdown

Script helpers implemented through Datastar element patches.

Summary

Functions

Logs a message in the browser console.

Executes JavaScript by appending a <script> element to body.

Formats an execute-script element patch without writing to a connection.

Redirects the browser to a URL.

Functions

console_log(conn, message, opts \\ [])

@spec console_log(Plug.Conn.t(), term(), keyword()) :: Plug.Conn.t()

Logs a message in the browser console.

execute(conn, script, opts \\ [])

@spec execute(Plug.Conn.t(), String.t(), keyword()) :: Plug.Conn.t()

Executes JavaScript by appending a <script> element to body.

format_execute(script, opts \\ [])

@spec format_execute(
  String.t(),
  keyword()
) :: String.t()

Formats an execute-script element patch without writing to a connection.

redirect(conn, url, opts \\ [])

@spec redirect(Plug.Conn.t(), String.t(), keyword()) :: Plug.Conn.t()

Redirects the browser to a URL.