MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

Printer

MMO.core · 1 symbol · generated 27 Oct 2026

class

Printer

Printer.js:17

Printer: render any value to text.

class MMO.core.Printer
Namespace
MMO.core
Use Shared instance: Printer try every renderer corresponding to the given format (opts.format), or the given types (opts.type)
render something: MMO.core.Printer.Shared().render(value); add a new renderer: MMO.core.Printer.Shared().setRenderer('datetime', (value, opts) => ...);MMO.core.Printer.Shared().render(false, {format: status, type: [null]}) This will cause the printer to try the following renderder: 'status', 'null', 'boolean' (from typeof value). If any renderer exists and returns a string or an Element, the printer will stop trying other renderer.

Index

constructor()
Shared(id) staticGet a shared printer, creating it (with the default renderers) on first use.
EntityNames(entries) staticThe name each entity of a list is shown by: its title, unless another entity of the same list has that title too (two establishments named « SIEGE - Courbevoie »): each of those also shows its labe…
setRenderer(format, fn, opts)Register how a format is rendered, replacing any previous renderer of that name.
getRenderer(format)
callRenderer(type, value, opts)Run one renderer, without the format/type resolution MMO.core.Printer#render does.
getOptions(format)
setOptions(format, opts)Replace a registered renderer's options.
render(value, opts)Render a value, trying the renderers in order until one accepts it: opts.format, then each of opts.type, then typeof value.
setDefaultRenderers()renderHeader(headerProperties, key) { if (headerProperties.contentRoot instanceof MMO.core.Map) { headerProperties = headerProperties.contentRoot.toObject(); } const currentHeader = headerPropertie…

Methods10

Shared(id)

staticPrinter.js:27

Get a shared printer, creating it (with the default renderers) on first use.

static Shared(id = '*')
id = '*'stringkeep several independent printers side by side
returnsMMO.core.Printer

EntityNames(entries)

staticPrinter.js:44

The name each entity of a list is shown by: its title, unless another entity of the same list has that title too (two establishments named « SIEGE - Courbevoie »): each of those also shows its label, what tells it apart, less the - parts its end shares with the title -- « SIEGE - Courbevoie (TRANSLOGIX Transport) » for the label « TRANSLOGIX Transport - Courbevoie » (my.oviepro #209). A label that tells nothing more adds nothing.

static EntityNames(entries)
entriesArraya list's entries: those that are not an MMO.elements.Entity are ignored
returnsMapMMO.elements.Entity => the name to show

setRenderer(format, fn, opts)

Printer.js:71

Register how a format is rendered, replacing any previous renderer of that name.

setRenderer(format, fn, opts = [])
formatstringa format name, a json type, or a typeof result
fnFunctionfunction(value, opts): string|Element|Array|null|false return null or false to decline the value and let the next renderer try
opts = []Objectoptions merged into every call's opts

getRenderer(format)

Printer.js:79
getRenderer(format)
formatstring
returns?Functionnull when nothing is registered

callRenderer(type, value, opts)

Printer.js:90

Run one renderer, without the format/type resolution MMO.core.Printer#render does.

callRenderer(type, value, opts)
typestringthe renderer's name
value*
optsObject
returnsstring | Element | Array | falsefalse when the renderer is missing or declined

getOptions(format)

Printer.js:104
getOptions(format)
formatstring
returns?Objectnull when nothing is registered under that name

setOptions(format, opts)

Printer.js:114

Replace a registered renderer's options.

setOptions(format, opts)
formatstring
optsObject
throwsMMO.Errorwhen nothing is registered under that name

render(value, opts)

Printer.js:126

Render a value, trying the renderers in order until one accepts it: opts.format, then each of opts.type, then typeof value.

render(value, opts = [])
value*
opts = []Objectformat, type, html and whatever the renderer reads
returnsstring | Element | Arraythe value stringified when no renderer matched

setDefaultRenderers()

Printer.js:162

renderHeader(headerProperties, key) { if (headerProperties.contentRoot instanceof MMO.core.Map) { headerProperties = headerProperties.contentRoot.toObject(); } const currentHeader = headerProperties[key]; if (!currentHeader.headerFormat) { return currentHeader.title; } return this.callRenderer(currentHeader.headerFormat, currentHeader); }

setDefaultRenderers()