Skip to content

Commit

Permalink
Fix typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
langyo committed Oct 15, 2024
1 parent 07cdfe1 commit a08096e
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 12 deletions.
4 changes: 2 additions & 2 deletions website/docs/concepts/basic-web-technologies/css.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem'
Yew does not natively provide a CSS-in-Rust solution but helps with styling by providing
programmatic ways to interact with the HTML `class` attribute.

## Classes
## `classes!` macro

The `classes!` macro and associated `Classes` struct simplify the use of HTML classes:

Expand Down Expand Up @@ -87,7 +87,7 @@ We will expand upon this concept in [more CSS](../../more/css).

## Inline Styles

Currently Yew does not provide any special help with inline styles specified via the `styles` attribute,
Currently Yew does not provide any special help with inline styles specified via the `style` attribute,
but you can use it like any other HTML attribute:

```rust
Expand Down
2 changes: 1 addition & 1 deletion website/docs/concepts/basic-web-technologies/html.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'HTML with html!'
description: 'Its HTML but not quite!'
description: 'It is HTML but not quite!'
comment: 'Keep this file as short and simple as possible. Its purpose is to ease the reader into components in Yew instead of providing proper API docs'
---

Expand Down
6 changes: 3 additions & 3 deletions website/docs/concepts/basic-web-technologies/wasm-bindgen.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ These implementations allow you to call a method from `A` on an instance of `C`
it was `&B` or `&A`.

It is important to note that every single type imported using `#[wasm-bindgen]` has the same root type,
you can think of it as the `A` in the example above, this type is [`JsValue`](#jsvalue) which has
you can think of it as the `A` in the example above, this type is [`JsValue`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html) which has
its section below.

_[extends section in The `wasm-bindgen` Guide](https://rustwasm.github.io/docs/wasm-bindgen/reference/attributes/on-js-imports/extends.html)_

### [`JsValue`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html) {#jsvalue}
### [`JsValue`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)

This is a representation of an object owned by JavaScript, this is a root catch-all type for `wasm-bindgen`.
Any type that comes from `wasm-bindgen` is a `JsValue` and this is because JavaScript does not have
Expand All @@ -117,7 +117,7 @@ being imported as to whether an exception (panic) will be raised if that value i

_[`JsValue` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)._

### [`JsCast`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html) {#JsCast}
### [`JsCast`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)

Rust has a strong type system and JavaScript...doesn't 😞. For Rust to maintain these
strong types but still be convenient, the WebAssembly group came up with a pretty neat trait `JsCast`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,55 @@ fn main() {
Example: [simple_ssr](https://github.com/yewstack/yew/tree/master/examples/simple_ssr)
Example: [ssr_router](https://github.com/yewstack/yew/tree/master/examples/ssr_router)

## Single thread mode

Yew supports single thread mode for server-side rendering by `yew::LocalServerRenderer`. This mode would work in a single thread environment like WASI.

```rust
// Build it by `wasm32-wasip1` target or `wasm32-wasip2` target (after rustc 1.78).
// You can still use `wasm32-wasi` target to build if you are using older version of rustc (before 1.84).
// See https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html for more information.

use yew::prelude::*;
use yew::LocalServerRenderer;

#[function_component]
fn App() -> Html {
use yew_router::prelude::*;

html! {
<>
<h1>{"Yew WASI SSR demo"}</h1>
</>
}
}

pub async fn render() -> String {
let renderer = LocalServerRenderer::<App>::new();
let html_raw = renderer.render().await;

let mut body = String::new();
body.push_str("<body>");
body.push_str("<div id='app'>");
body.push_str(&html_raw);
body.push_str("</div>");
body.push_str("</body>");

body
}

#[tokio::main(flavor = "current_thread")]
async fn main() {
println!("{}", render().await);
}
```

Example: [wasi_ssr_module](https://github.com/yewstack/yew/tree/master/examples/wasi_ssr_module)

:::note
If you are using the `wasm32-unknown-unknown` target to build a SSR application, you can use the `not_browser_env` feature flag to disable access of browser-specific APIs inside of Yew. This would be useful on serverless platforms like Cloudflare Worker.
:::

:::caution

Server-side rendering is currently experimental. If you find a bug, please file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem'
Yew does not natively provide a CSS-in-Rust solution but helps with styling by providing
programmatic ways to interact with the HTML `class` attribute.

## Classes
## `classes!` macro

The `classes!` macro and associated `Classes` struct simplify the use of HTML classes:

Expand Down Expand Up @@ -87,7 +87,7 @@ We will expand upon this concept in [more CSS](../../more/css).

## Inline Styles

Currently Yew does not provide any special help with inline styles specified via the `styles` attribute,
Currently Yew does not provide any special help with inline styles specified via the `style` attribute,
but you can use it like any other HTML attribute:

```rust
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'HTML with html!'
description: 'Its HTML but not quite!'
description: 'It is HTML but not quite!'
comment: 'Keep this file as short and simple as possible. Its purpose is to ease the reader into components in Yew instead of providing proper API docs'
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ These implementations allow you to call a method from `A` on an instance of `C`
it was `&B` or `&A`.

It is important to note that every single type imported using `#[wasm-bindgen]` has the same root type,
you can think of it as the `A` in the example above, this type is [`JsValue`](#jsvalue) which has
you can think of it as the `A` in the example above, this type is [`JsValue`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html) which has
its section below.

_[extends section in The `wasm-bindgen` Guide](https://rustwasm.github.io/docs/wasm-bindgen/reference/attributes/on-js-imports/extends.html)_

### [`JsValue`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html) {#jsvalue}
### [`JsValue`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)

This is a representation of an object owned by JavaScript, this is a root catch-all type for `wasm-bindgen`.
Any type that comes from `wasm-bindgen` is a `JsValue` and this is because JavaScript does not have
Expand All @@ -117,7 +117,7 @@ being imported as to whether an exception (panic) will be raised if that value i

_[`JsValue` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)._

### [`JsCast`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html) {#JsCast}
### [`JsCast`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)

Rust has a strong type system and JavaScript...doesn't 😞. For Rust to maintain these
strong types but still be convenient, the WebAssembly group came up with a pretty neat trait `JsCast`.
Expand Down

0 comments on commit a08096e

Please sign in to comment.