Directive
type Directive =
{
DirectiveName: string
Decode: int -> string -> Result<obj,string>
RenderWith: DirectiveContext -> obj -> ReactElement -> ReactElement
}| Assembly | Partas.Nacara.Plugins.Directives |
A directive: its name, how to read its arguments, what to render.
Neither function is generic, because directives of different argument types sit in one list. The type the author declared is restored inside them, which is why they are not public.
Fields
Decode: int -> string -> Result<obj,string>
Decode: int -> string -> Result<obj,string>Reads the opening line's arguments, boxed so directives of different argument types can sit in one list.
RenderWith: DirectiveContext -> obj -> ReactElement -> ReactElement
RenderWith: DirectiveContext -> obj -> ReactElement -> ReactElementRenders the directive, unboxing what Decode produced.
Functions and values
create<'T> (name: string) (decoder: Decoder<'T>) : DirectiveBuilder<'T>
create<'T> (name: string) (decoder: Decoder<'T>) : DirectiveBuilder<'T>Begin declaring a directive: its name and how to read its arguments.
| Parameter | |
|---|---|
name | The word an author writes after :::. |
decoder | How the directive's opening-line arguments are read. |
render<'T> (render: DirectiveContext -> 'T -> ReactElement -> ReactElement) (builder: DirectiveBuilder<'T>) : Directive
render<'T> (render: DirectiveContext -> 'T -> ReactElement -> ReactElement) (builder: DirectiveBuilder<'T>) : DirectiveFinish declaring a directive by saying how to render it.
| Parameter | |
|---|---|
render | Given the context, the decoded arguments, and the already-rendered body, returns the element placed wherever the directive belongs. |
builder | The directive declared by create. |