Printer
MMO.core · 1 symbole · générée le 27 Oct 2026
Printer
Printer.js:17Printer: render any value to text.
- Espace de noms
MMO.core
Index
| constructor() | ||
| Shared(id) static | Get a shared printer, creating it (with the default renderers) on first use. | |
| EntityNames(entries) static | 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 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… |
Méthodes10
constructor()
Printer.js:18Shared(id)
staticPrinter.js:27Get a shared printer, creating it (with the default renderers) on first use.
| id = '*' | string | keep several independent printers side by side |
| retourne | MMO.core.Printer |
EntityNames(entries)
staticPrinter.js:44The 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.
| entries | Array | a list's entries: those that are not an MMO.elements.Entity are ignored |
| retourne | Map | MMO.elements.Entity => the name to show |
setRenderer(format, fn, opts)
Printer.js:71Register how a format is rendered, replacing any previous renderer of that name.
| format | string | a format name, a json type, or a typeof result |
| fn | Function | function(value, opts): string|Element|Array|null|false return null or false to decline the value and let the next renderer try |
| opts = [] | Object | options merged into every call's opts |
getRenderer(format)
Printer.js:79| format | string | |
| retourne | ?Function | null when nothing is registered |
callRenderer(type, value, opts)
Printer.js:90Run one renderer, without the format/type resolution MMO.core.Printer#render does.
| type | string | the renderer's name |
| value | * | |
| opts | Object | |
| retourne | string | Element | Array | false | false when the renderer is missing or declined |
getOptions(format)
Printer.js:104| format | string | |
| retourne | ?Object | null when nothing is registered under that name |
setOptions(format, opts)
Printer.js:114Replace a registered renderer's options.
| format | string | |
| opts | Object | |
| lève | MMO.Error | when nothing is registered under that name |
render(value, opts)
Printer.js:126Render a value, trying the renderers in order until one accepts it: opts.format, then each of opts.type, then typeof value.
| value | * | |
| opts = [] | Object | format, type, html and whatever the renderer reads |
| retourne | string | Element | Array | the value stringified when no renderer matched |
setDefaultRenderers()
Printer.js:162renderHeader(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); }