@barefootjs/cli 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -12,6 +12,27 @@ npm install @barefootjs/go-template
|
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
## Server integration
|
|
16
|
+
|
|
17
|
+
The adapter is **web-framework-agnostic** — it emits plain Go `html/template`
|
|
18
|
+
files plus a small runtime (`FuncMap`, `Renderer`), so any server that can
|
|
19
|
+
parse and execute `html/template` can render the output. The scaffolder
|
|
20
|
+
(`npm create barefootjs@latest -- --adapter <name>`) ships runnable starters
|
|
21
|
+
for four Go servers, all built on this adapter:
|
|
22
|
+
|
|
23
|
+
| `--adapter` | Framework | Router |
|
|
24
|
+
|-------------|-----------|--------|
|
|
25
|
+
| `echo` | [Echo](https://echo.labstack.com/) | `echo.Renderer` |
|
|
26
|
+
| `gin` | [Gin](https://gin-gonic.com/) | `gin.Engine` |
|
|
27
|
+
| `chi` | [Chi](https://go-chi.io/) | `chi.Router` (net/http) |
|
|
28
|
+
| `nethttp` | Go standard library | `http.ServeMux` |
|
|
29
|
+
|
|
30
|
+
Each scaffold loads the generated `.tmpl` files into a `template.Template`
|
|
31
|
+
with `bf.FuncMap()`, then renders a component through `bf.NewRenderer(...)`.
|
|
32
|
+
Runnable end-to-end examples for all four live under
|
|
33
|
+
[`integrations/`](https://github.com/piconic-ai/barefootjs/tree/main/integrations).
|
|
34
|
+
|
|
35
|
+
|
|
15
36
|
## Basic Usage
|
|
16
37
|
|
|
17
38
|
```typescript
|
|
@@ -221,6 +242,14 @@ export function TodoList({ items }: { items: TodoItem[] }) {
|
|
|
221
242
|
}
|
|
222
243
|
```
|
|
223
244
|
|
|
245
|
+
Child component props carry a `ScopeID` used for hydration. You don't have to
|
|
246
|
+
mint these by hand: `bf.Renderer.Render` backfills a unique
|
|
247
|
+
`<Component>_<random>` id for any child (in a slice or a single field) whose
|
|
248
|
+
`ScopeID` is empty — the same shape the generated `New{Component}Props()`
|
|
249
|
+
constructor uses. Build child props with just the data they need (e.g.
|
|
250
|
+
`TodoItemProps{Todo: t}`) and the runtime fills in the rest. Setting `ScopeID`
|
|
251
|
+
explicitly still works and is preserved when you need a stable id.
|
|
252
|
+
|
|
224
253
|
## Conditional Rendering
|
|
225
254
|
|
|
226
255
|
Ternaries become `{{if}}...{{else}}...{{end}}`:
|
|
@@ -26,6 +26,8 @@ JSX Source
|
|
|
26
26
|
|
|
27
27
|
> CSR is not an IR→template adapter. It renders components directly in the browser using client-side template functions — use it when the server can't (or shouldn't) emit the initial HTML.
|
|
28
28
|
|
|
29
|
+
The `GoTemplateAdapter` is web-framework-agnostic: its `html/template` output runs on any Go server. `npm create barefootjs@latest` ships scaffolds for Echo, Gin, Chi, and net/http (via `--adapter`) — see [Go Template Adapter → Server integration](./adapters/go-template-adapter.md#server-integration).
|
|
30
|
+
|
|
29
31
|
## Pages
|
|
30
32
|
|
|
31
33
|
| Topic | Description |
|
|
@@ -152,10 +152,10 @@ This runs `bf build`, generates the final `uno.css`, and calls `wrangler deploy`
|
|
|
152
152
|
- **[`createSignal`](./reactivity/create-signal.md)** and **[`createMemo`](./reactivity/create-memo.md)** — the reactivity primitives you just used.
|
|
153
153
|
- **[Client Directive](./rendering/client-directive.md)** — exactly what `"use client"` does and when to reach for it.
|
|
154
154
|
- **[Hono Adapter](./adapters/hono-adapter.md)** — adapter-specific configuration and output details.
|
|
155
|
-
- Pick a different backend by passing `--adapter` to the scaffolder. Supported values today: `hono` (default — Cloudflare Workers), `hono-node`, `echo` (Go / Echo), `mojo` (Mojolicious / Perl), `csr` (no backend — pure client render). For example:
|
|
155
|
+
- Pick a different backend by passing `--adapter` to the scaffolder. Supported values today: `hono` (default — Cloudflare Workers), `hono-node`, `echo` (Go / Echo), `gin` (Go / Gin), `chi` (Go / Chi), `nethttp` (Go / net/http stdlib), `mojo` (Mojolicious / Perl), `csr` (no backend — pure client render). For example:
|
|
156
156
|
|
|
157
157
|
```bash
|
|
158
158
|
npm create barefootjs@latest -- --adapter hono-node
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
See [Adapter Architecture](./adapters/adapter-architecture.md) for the architectural overview, and the per-adapter pages under [`docs/core/adapters/`](./adapters/) for output details. The `@barefootjs/go-template`
|
|
161
|
+
See [Adapter Architecture](./adapters/adapter-architecture.md) for the architectural overview, and the per-adapter pages under [`docs/core/adapters/`](./adapters/) for output details. The four Go scaffolds (`echo`, `gin`, `chi`, `nethttp`) all build on the `@barefootjs/go-template` adapter, which generates Go `html/template` files; see [Go Template Adapter](./adapters/go-template-adapter.md) for its programmatic API.
|