inertia_wisp/html
HTML layout helpers for Inertia.js applications.
This module provides utilities for creating HTML layouts that embed Inertia page data. You can use these as-is or as examples for your own layouts.
Values
pub fn default_layout(
component_name: String,
page_data: json.Json,
) -> String
A simple default HTML layout for development and getting started.
This layout includes:
- UTF-8 charset and viewport meta tags
- Component name as page title
- A div with id=“app” and data-page attribute containing the Inertia data
- A script tag loading
/static/js/main.jsas an ES module - A link to
/static/css/styles.css
Example
|> inertia.response(200, html.default_layout)
pub fn escape_html(text: String) -> String
Escape HTML characters for safe insertion into attributes.
This function escapes characters that have special meaning in HTML to prevent XSS attacks and ensure the JSON data is properly embedded.
Example
html.escape_html("<script>alert('xss')</script>")
// Returns: "<script>alert('xss')</script>"