Skip to content

Commit

Permalink
Added building and deployment of wasm-demo.
Browse files Browse the repository at this point in the history
Refactored examples to better fit with the generated demo page.
  • Loading branch information
KaruroChori committed Jan 9, 2025
1 parent d8ef9e3 commit bbc1c88
Show file tree
Hide file tree
Showing 34 changed files with 87 additions and 92 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
permissions:
contents: write
pages: write
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v1
Expand All @@ -58,6 +59,23 @@ jobs:
with:
files: |
./build/vs.templ.js
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Build wasm-demo
run: |
cp -R examples ./dist/wasm-demo/static
cp ./build/vs.templ.js ./dist/wasm-demo/static
cd ./dist/wasm-demo
bun install
bun run build
- name: Deploy wasm-demo
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist/wasm-demo/build/
destination_dir: wasm-demo

docs:
uses: ./.github/workflows/docs.yml
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ It can be used to statically generate new files from a template definition and a
Static templates can be seen as extremely simple programs serialized in XML which are interpreted by this preprocessor.
They consume input data (also XML) to generated output XML.

Details about the syntax & supported features are covered in a [dedicated page](./docs/syntax.md), or you might want to check some [examples](./examples/).
Details about the syntax & supported features are covered in a [dedicated page](https://lazy-eggplant.github.io/vs.templ/next/docs), or you might want to check some [examples](https://lazy-eggplant.github.io/vs.templ/wasm-demo/).

## Examples

Expand Down Expand Up @@ -43,9 +43,7 @@ results in
</ul>
```

### Conditional rendering

To be written
For more examples check the [online playground](https://lazy-eggplant.github.io/vs.templ/wasm-demo/)!

## Usage

Expand Down
40 changes: 25 additions & 15 deletions dist/wasm-demo/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,41 @@
PreopenDirectory,
} from "@bjorn3/browser_wasi_shim";
const example_basic_entry = (str, title)=> {
return {
value: str,
title: title ?? `s:${str}`,
template: `./examples/basics/${str}/templ.xml`,
data: `./examples/basics/${str}/data.xml`
};
}
const examples = [
{
title: "Basics",
items: [
{
value: "default",
title: "Hello world",
template: "./examples/basics/default/template.xml",
data: "./examples/basics/default/data.xml",
},
{
value: "for",
title: "s:for",
template: "./examples/basics/for/template.xml",
data: "./examples/basics/for/data.xml",
},
example_basic_entry("default", "Hello world!"),
example_basic_entry("value"),
example_basic_entry("element"),
example_basic_entry("for-range"),
example_basic_entry("for"),
example_basic_entry("for-props"),
example_basic_entry("test"),
example_basic_entry("data"),
//example_basic_entry("include"),
],
},
{
title: "Expressions",
items: [],
},
{
title: "Demos",
items: [
{
value: "HTML Generation",
template: "./examples/advanced/html/template.xml",
data: "./examples/advanced/html/data.xml",
template: "./examples/advanced/html/templ.xml",
data: "./examples/advanced/html/data.0.xml",
},
],
},
Expand Down Expand Up @@ -183,7 +193,7 @@
<PaneGroup direction="vertical">
<Pane defaultSize={50}>
<nav style="padding-left:0px;">
<div class="logo"><a href="/">vs.templ</a></div>
<div class="logo"><a href="https://lazy-eggplant.github.io/vs.templ">vs.templ</a></div>
<div class="tabs">
<a
onclick={() => change_view("template")}
Expand Down
2 changes: 1 addition & 1 deletion dist/website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
Source</button></a>
<a href="./docs"><button><i class="fa-solid fa-book"></i> Main documentation</button></a>
<a href="./doxygen/html"><button><i class="fa-solid fa-book"></i> Doxygen reference</button></a>
<a href="./wasm-demo"><button>Online demo</button></a>
<a href="../wasm-demo"><button>Online demo</button></a>
<button disabled><i class="fa-solid fa-comment"></i> Help</button>
</nav>
<hr />
Expand Down
41 changes: 0 additions & 41 deletions dist/website/wasm-demo.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
./build/vs.templ ./examples/html/template.xhtml5 ./examples/html/page-0.xml
./build/vs.templ ./examples/advanced/html/template.xml ./examples/advanced/html/data.0.xml
-->

<entry title="Page 0">
Expand Down
5 changes: 5 additions & 0 deletions examples/advanced/html/data.1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!--
./build/vs.templ ./examples/advanced/html/template.xml ./examples/advanced/html/data.1.xml
-->
<entry title="Page 1">
</entry>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<body>
<main class="container">
<h1 s:when=": false">Hello!</h1>
<s:include src="./examples/html/header.xhtml5">
<s:include src="./examples/advanced/html/header.template.xml">
<h1>Placeholder title</h1>
<p>Description stuff</p>
</s:include>
Expand Down
4 changes: 0 additions & 4 deletions examples/basic-features/data.data.xml

This file was deleted.

4 changes: 0 additions & 4 deletions examples/basic-features/element.data.xml

This file was deleted.

4 changes: 0 additions & 4 deletions examples/basic-features/for-range.data.xml

This file was deleted.

4 changes: 0 additions & 4 deletions examples/basic-features/test.data.xml

This file was deleted.

4 changes: 0 additions & 4 deletions examples/basic-features/value.data.xml

This file was deleted.

4 changes: 4 additions & 0 deletions examples/basics/data/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!--
`./build/vs.templ ./examples/basics/data.templ.xml ./examples/basics/data.data.xml`
-->
<data></data>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<document xmlns:s="vs.templ">
<h1>Section A</h1>
<ul>
<s:data tag="DATA" src="./examples/basic-features/data.ext-data.xml">
<s:data tag="DATA" src="./examples/basics/data/ext-data.xml">
<s:for in="{DATA}/items/section-b/" sort-by="$~prop-a" order-by="desc">
<s:header>
<h3>Header</h3>
Expand Down
3 changes: 3 additions & 0 deletions examples/basics/default/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<root msg="Hello world!">
<!--Data goes here, feel free to structure this file as you want-->
</root>
7 changes: 7 additions & 0 deletions examples/basics/default/templ.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:s="vs.templ">
<body>
<h1>Template</h1>
<s:value src="/root~msg" />
</body>
</html>
4 changes: 4 additions & 0 deletions examples/basics/element/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!--
`./build/vs.templ ./examples/basics/element/templ.xml ./examples/basics/element/data.xml`
-->
<data></data>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
`./build/vs.templ ./examples/basic-features/for-props.templ.xml ./examples/basic-features/for-props.data.xml`
`./build/vs.templ ./examples/basics/for-props.templ.xml ./examples/basics/for-props.data.xml`
-->
<items>
<section-a prop-a="Value A-1" prop-b="Value A-2" prop-c="Value A-3"></section-a>
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions examples/basics/for-range/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!--
`./build/vs.templ ./examples/basics/for-range/templ.xml ./examples/basics/for-range/data.xml`
-->
<data></data>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
`./build/vs.templ ./examples/basic-features/for.templ.xml ./examples/basic-features/for.data.xml`
`./build/vs.templ ./examples/basics/for/templ.xml ./examples/basics/for/data.xml`
-->
<items>
<item prop-a="Value-E">Text E</item>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Test with:
`./build/vs.templ ./examples/basic-features/old.templ.xml ./examples/basic-features/old.data.xml`
`./build/vs.templ ./examples/basics/old.templ.xml ./examples/basics/old.data.xml`
from the source root.
-->

Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions examples/basics/test/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!--
`./build/vs.templ ./examples/basics/test/templ.xml ./examples/basics/test/data.xml`
-->
<data></data>
File renamed without changes.
4 changes: 4 additions & 0 deletions examples/basics/value/data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!--
`./build/vs.templ ./examples/basics/value/templ.xml ./examples/basics/value/data.xml`
-->
<data></data>
File renamed without changes.
5 changes: 0 additions & 5 deletions examples/html/page-1.xml

This file was deleted.

0 comments on commit bbc1c88

Please sign in to comment.