Skip to content

Commit dfdfb78

Browse files
author
checkroom
committed
Extended the specifications for static components.
1 parent e160ac2 commit dfdfb78

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

docs/static-components.md

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,72 @@
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`
3962
Like for `vs.templ`.
4063

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

4472
## Examples
4573

0 commit comments

Comments
 (0)