Files
wren/example/jinja_markdown.wren
T
retoor 46fc2e2470 feat: add async/await keywords, Num/String extensions, and Jinja markdown example
Add `async` and `await` token support to the Wren compiler with scheduler resolution logic, extend `Num` with `e` constant, hyperbolic trig, base conversion, and new methods (`isZero`, `gcd`, `lcm`, `digits`, etc.), extend `String` with `lower`, `upper`, `capitalize`, `title`, and regenerate `wren_core.wren.inc`. Include `Makefile` for multi-platform builds, rewrite `README.md` with updated build instructions, and add `example/await_demo.wren` and `example/jinja_markdown.wren` demonstrating new features.
2026-01-25 03:58:39 +00:00

68 lines
1.7 KiB
JavaScript
Vendored

// retoor <retoor@molodetz.nl>
import "jinja" for Environment, DictLoader
System.print("=" * 60)
System.print("JINJA MARKDOWN - Markdown/HTML Conversion in Templates")
System.print("=" * 60)
var templates = {
"md_to_html": "{\% markdowntohtml \%}# {{ title }}
{{ description }}
- Item **one**
- Item **two**
- Item **three**
{\% endmarkdowntohtml \%}",
"html_to_md": "{\% markdownfromhtml \%}<h1>{{ title }}</h1>
<p>This is a <strong>paragraph</strong> with <em>formatting</em>.</p>
<ul>
<li>First</li>
<li>Second</li>
</ul>{\% endmarkdownfromhtml \%}",
"filter_md": "{{ content|markdown }}",
"filter_fromhtml": "{{ content|markdownfromhtml }}",
"mixed": "<div class=\"article\">
{\% markdowntohtml \%}## {{ article.title }}
{{ article.body }}
{\% endmarkdowntohtml \%}
</div>"
}
var env = Environment.new(DictLoader.new(templates))
System.print("\n--- Markdown to HTML (block tag) ---")
System.print(env.getTemplate("md_to_html").render({
"title": "Welcome",
"description": "This is a *template* with markdown support."
}))
System.print("\n--- HTML to Markdown (block tag) ---")
System.print(env.getTemplate("html_to_md").render({
"title": "Documentation"
}))
System.print("\n--- Markdown filter ---")
System.print(env.getTemplate("filter_md").render({
"content": "**Bold** and *italic* text."
}))
System.print("\n--- Markdown from HTML filter ---")
System.print(env.getTemplate("filter_fromhtml").render({
"content": "<h2>Section</h2><p>A paragraph.</p>"
}))
System.print("\n--- Mixed HTML and Markdown ---")
System.print(env.getTemplate("mixed").render({
"article": {
"title": "Getting Started",
"body": "Read the **documentation** for details."
}
}))