asCodeBlock
Marks a value so that createFragmentWithCodeBlocks renders it as an inline code block.
Wrap a value with this before handing it to t(), and the translated message comes back with the value already in place, delimited:
createFragmentWithCodeBlocks(t(($) => $.obsidianDevUtils.pluginSuggestion.installed, { pluginName: asCodeBlock(pluginName)}));The marker travels WITH the value rather than being a positional placeholder the caller matches up afterwards. That distinction is the whole point: a message naming two plugins is interpolated by name, and a translation is free to put them in either order, so anything that re-associated values with placeholders by position would silently swap them the moment a sentence read the other way round.
Import:
import { asCodeBlock } from 'obsidian-dev-utils/obsidian/html-element';Signature:
function asCodeBlock(value: string): stringParameters:
| Parameter | Type | Description |
|---|---|---|
value | string | The value to render as a code block. |
Returns: string — The value, delimited for createFragmentWithCodeBlocks.
Links to this page: