Skip to content

Skribi Module

Property of skTypeDescription
v {[key: string]: string} Contains variables passed to the template. In a non-template context, this object is empty.
child Object Contains functions related to the MarkdownRenderChild.
ctx Object Contains direct references to various objects.
  • plugin: SkribosPlugin: A reference to the Skribi plugin.
  • file?: TFile: The file inside of which the skribi is being rendered. Null if not being rendered inside of a file.
  • app: App: The Obsidian app.
this Object A reference to the template function's bound `this` object. Possibly useful for storing values to be accessed by scripts.
sk.has(val: string) => boolean Returns true if the property val exists on sk.v.
sk.render(text: string) => string Renders text as Obsidian Markdown inside a virtual element, then returns the element's innerHTML.
sk.abort(msg?: string, data?: any) => void Aborts the render execution and renders an error block. Using this function provides finer control of error displays (useful for those making templates intended for use by others). If no arguments are provided, will render a generic 'abort' indicator. msg is equivalent to the message argument of an error constructor and may be null. The data argument can optionally contain additional properties. Valid properties (all optional):
  • name: string - Overwrites error name.
  • cls: string - CSS classes to apply to the error indicator, space separated. (default: 'skr-abort')
  • hover: string - The message shown on mouse hover (default: msg or "Evaluation Aborted")
  • label: string - The text shown in the block (default: 'sk')
sk.getStyle(styleName: string) async => Promise<string> Returns a promise for the text content of the file styleName.css in the template directory, if it exists. Resolves on completion of initial template load (instant if already complete).
sk.includeStyle(styleName: string) async => Promise<CSSStyleElement> Returns a promise for a style element that has been attached and scoped to the skribi, with the content of file styleName.css in the template directory. Resolves when both initial caching is complete and the skribi has been connected to the document (thus, awaiting this function directly will cause skribi to hang). Also causes the skribi to listen for and update on modifications to said css file.
sk.up(key: string, value: any) => void Passes data up to the render process. Valid keys:
  • noMarkdown - if truthy, markdown rendering will be skipped and the template function output treated as the innerHTML of the container element. You may still get rendered markdown with <%~ sk.render(markdownString) %>.

sk.child

Property of sk.childTypeDescription
el HTMLDivElement The element to which the rendered `tR` nodes will be added. Note that this element is empty and not attached to the document until *after* the execution is complete.
reload(id?: string) => void Force the skribi to re-process itself, unloading the current child in the process. If the skribi type is template, providing id will use a freshly retrieved version of that template as its source (used by Auto Reload).
registerInterval(cb: Function, t: number, ...args: any[]) => void Registers the function `cb` to be called every t seconds with the arguments args. Interval is cleared on unload.
registerPost(cb: Function, ...args: any[]) => void Registers the function cb to be called after the skribi render function has been fullfilled and sk.child.el appended to the view. Called before embeds are rendered.
registerUnload(cb: Function, ...args: any[]) => void Registers a function to called on child unload, which occurs when the element or child is destroyed. Use this to clear references as necessary.
registerEvent(event: EventRef) => void Registers an EventRef to be safely offref'd on unload.
addStyle(text: string) async => Promise<CSSStyleElement> Creates and attaches style element composed from the CSS-parsable string text. Returns a promise that resolves after the skribi function resolves and is attached to the document. Awaiting this value directly will thus cause the skribi function to hang.
_c SkribiChild A direct reference to the child object. Not really intended to be accessed, just in case you wanna reach in there directly with your nasty code fingers.