yew/examples
Simon d792e37bff
Unify and change children logic in the html macro (#1275)
* add test to assert iterators work

* update test

* a few minor adjustments

* remove redundant wrappers around htmltree

* we're going down the rabbit hole

* components are broken but everything else works

* we're getting there

* working prototype

* test vector as children method for all containers

* more appropriate names and some comments

* ChildrenRenderer handling

* update tests to include ChildrenRenderer

* trigger tests to re-run

* improve error messages for invaid iterables

* improve html_nested!
2020-06-09 09:34:23 +08:00
..
2020-05-13 10:52:33 +08:00
2020-05-21 22:21:41 +08:00

Yew Examples

In order to build the examples, use the build.sh script.

All the examples are designed to work with wasm-bindgen except for examples in folders ending in _wp (these are prepared for wasm-pack).

  • The examples do not use external bundlers and all use the same static/index.html after being built.
  • wasm-bindgen builds projects as binary crates (main.rs)
  • wasm-pack builds projects as library crates (lib.rs)

Have a look at Yew's starter templates when starting a project using Yew  they can significantly simplify things.

How to run the examples

git clone https://github.com/yewstack/yew.git
cd yew/examples
./build.sh minimal # example subfolder
python3 -m http.server --directory static # open localhost:8000 in browser

Note: Visual Studio Code has an extension called Live Server which can be used to run examples in the browser (with automatic page refreshes when a file is changed). After installing the extension open index.html and press Open with Live Server in the context menu.

Requirements

The default way to build the examples is by using wasm-bindgen (this is automatically installed if you've installed wasm-pack). If they aren't installed, these tools can be installed by using cargo (cargo install wasm-pack wasm-bindgen-cli).

Installation guides: Rust and wasm-pack

# rust install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# wasm-pack install
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh;
# wasm-bindgen-cli install
cargo install wasm-bindgen-cli