Skip to content

Commit b541ad3

Browse files
checkroomKaruroChori
authored andcommitted
Extended the specifications for static components.
1 parent e160ac2 commit b541ad3

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

docs/static-components.md

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,74 @@
22
> These specs are not part of `vs.templ`.
33
> They are just temporarily hosted here to decide what to do about that.
44
5+
## What is this
6+
These are specifications for an agnostic component model based on XML.
7+
It allows packaging code as single file components, and reuse it inside others.
8+
59
## Tags and attributes
610

711
### `ns:component`
8-
Root for components
9-
Any attribute is considered as default value for when it is later injected.
12+
Root for any component.
13+
Further attributes will be assumed as default values for when they are later injected.
1014

1115
### `ns:section`
12-
- [ ] `type`
16+
A section inside the component, to logically split its content and let the downstream application handle it on its own.
17+
- [ ] `type` a marker, usually in the form `logic-function/format`. Used as metadata downstream.
18+
Any other argument will also be handled downstream.
1319

1420
### `ns:import`
15-
- [ ] `src`
16-
- [ ] `as` (optional)
21+
- [ ] `src` a path-like to the object to import, handled externally
22+
- [ ] `as` (optional) a name to use the resource, if not provided downstream will assign one based on path
23+
Any other attribute is accepted, and will be package as part of the import request.
24+
25+
Body content is used as alternative if loading fails.
1726

18-
Body is the alternative if loading fails.
27+
### `ns:include`
28+
- [ ] `src` a path-like to the object to import, handled externally
29+
In-place substitution of content. Used to introduce global things in the component scope.
30+
31+
Body content is used as alternative if loading fails.
1932

2033
### `ns:use`
2134
- [ ] `s:src` either path or local resolution with prefix `#`
35+
Any other attribute is passed on.
36+
Body contains slots, some of which have special features, allowing for error handling for example.
37+
38+
### `ns-x:*` namespace
39+
Elements in this namespace are shorthands for the `use` command.
2240

2341
### `ns:slot`
2442
- [ ] `s:name` identifier for the slot. If empty it is the default one. Special name `error` in case of component failure.
43+
Any further argument is applied to the injection location.
44+
45+
Its body is also for injection.
2546

2647
### `ns:inject` as element
2748
- [ ] `src`
28-
Body is default in case the injection fails
49+
Body is default for cases in which the injection fails.
2950

30-
### `ns:inject.xxx` and `ns:inject-default.xxx` as props
51+
### `ns:inject.src.xxx` and `ns:inject.defval.xxx` as props
52+
Like their element counterpart, with the restriction of being simple strings as they operate on attributes.
3153

3254
### `ns:scope`
33-
It just forces a new scope in which imports can hide what came before.
55+
It just forces a new scope in which imports and mixins can hide what came before.
3456
Totally optional, each component imposes its own scope, and the parent one is not being inherited.
3557

3658
### `ns:throw`
59+
To close the process early. At times an error is so bad that it is not possible to continue.
3760

3861
### `ns:debug`
39-
Like for `vs.templ`.
62+
Like for `vs.fltk`.
63+
- [ ] `type` enum with values from `warning`, `info`, `panic`, `ok`, `error`, `log` with `log` being default.
64+
- [ ] `msg` as a string
4065

41-
### `ns-x:*` namespace
42-
It references any imported component which appeared before.
66+
### `ns:mixin`
67+
- [ ] `ns:rule`
68+
All the other attributes are part of the mixin definition.
69+
70+
### `ns:mixins` attribute
71+
To apply a list of mixins to the current element, beyond those which are implicitly applied.
72+
Mixins are **always** evaluated and replaced in place. They don't pass barriers between components.
4373

4474
## Examples
4575

0 commit comments

Comments
 (0)