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.
This commit is contained in:
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// 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)")
|
||||
Reference in New Issue
Block a user