Files
wren/example/html_demo.wren
T
retoor 5a4054ec66 feat: add example scripts for argparse, bytes, dataset, html, markdown, uuid, wdantic, and web chat modules
Add comprehensive demo scripts showcasing the usage of multiple Wren modules including argument parsing, byte manipulation, in-memory dataset operations, HTML encoding/slugification, markdown-to-HTML conversion, UUID generation/validation, schema validation with wdantic, and a full web chat application with REST endpoints.
2026-01-24 22:40:22 +00:00

40 lines
1.1 KiB
JavaScript
Vendored

// retoor <retoor@molodetz.nl>
import "html" for Html
System.print("=== HTML Module Demo ===")
System.print("\n--- URL Encoding ---")
var text = "hello world & special=chars"
var encoded = Html.urlencode(text)
var decoded = Html.urldecode(encoded)
System.print("Original: %(text)")
System.print("Encoded: %(encoded)")
System.print("Decoded: %(decoded)")
System.print("\n--- Slugify ---")
var titles = [
"Hello World",
"This is a Test Article!",
"Product Name (2024)",
"FAQ & Help"
]
for (title in titles) {
System.print("%(title) -> %(Html.slugify(title))")
}
System.print("\n--- HTML Escaping ---")
var unsafe = "<script>alert('XSS')</script>"
var safe = Html.quote(unsafe)
System.print("Unsafe: %(unsafe)")
System.print("Safe: %(safe)")
System.print("Unescaped: %(Html.unquote(safe))")
System.print("\n--- Query Parameters ---")
var params = {"name": "John Doe", "city": "New York", "age": 30}
var queryString = Html.encodeParams(params)
System.print("Params: %(params)")
System.print("Query string: %(queryString)")
var parsed = Html.decodeParams(queryString)
System.print("Parsed back: %(parsed)")