Skip to content

Directive

type Directive =
    {
        DirectiveName: string
        Decode: int -> string -> Result<obj,string>
        RenderWith: DirectiveContext -> obj -> ReactElement -> ReactElement
    }
AssemblyPartas.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

DirectiveName: string

The word after :::.

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

Renders the directive, unboxing what Decode produced.

Functions and values

create<'T> (name: string) (decoder: Decoder<'T>) : DirectiveBuilder<'T>

Begin declaring a directive: its name and how to read its arguments.

Parameter
nameThe word an author writes after :::.
decoderHow the directive's opening-line arguments are read.
render<'T> (render: DirectiveContext -> 'T -> ReactElement -> ReactElement) (builder: DirectiveBuilder<'T>) : Directive

Finish declaring a directive by saying how to render it.

Parameter
renderGiven the context, the decoded arguments, and the already-rendered body, returns the element placed wherever the directive belongs.
builderThe directive declared by create.

Properties

member Name: string

The word after ::: that selects this directive.