Code
Code gives editors a proper code editor, with syntax highlighting, line numbers and indentation, for things like an embed snippet, a JSON configuration or an example on a documentation site.
The code is stored exactly as typed, with its whitespace and line breaks. When you display it, for example by binding it to a core Code block with a dynamic tag, the markup is shown as text, not run on the page.
Settings
- Default language sets the syntax highlighting. 28 languages are available, including HTML, CSS, JavaScript, PHP, JSON, SQL and Markdown.
- Allow editor to switch language lets editors pick a different language per entry; Restrict languages to limits that choice.
- Show filename input adds a filename box above the editor, useful for documentation snippets.
- Theme (Auto, Light or Dark), Show line numbers, Wrap long lines, Indentation (spaces or tabs) and Indent size, and the editor's minimum and maximum height in rows.
- Min length and Max length.
Warning
Code isn't a way to add scripts to your site. VX displays the stored code as text; it never runs it. To add working embeds, use a block or your theme.
Technical details for LLMs
- Type key:
code. Settings:language(defaulthtml),language_selectable,allowed_languages,show_filename,theme(auto|light|dark),line_numbers(true),line_wrapping(true),indent_type(spaces|tabs),indent_size(1–8, default 2),min_rows(6),max_rows(12),minlength,maxlength,placeholder,default_value. - Languages:
plaintext,bash,css,diff,go,html,http,java,javascript,json,jsx,liquid,markdown,nginx,php,php_implicit,python,ruby,rust,sass,scss,shell,sql,twig,typescript,tsx,vue,xml. - Stored: JSON
{ code, language, filename }. Abilities read:{ content, language, filename }(the code iscontent); write:{ code, language?, filename? }or a bare string. Asymmetric: readcontent, writecode. - PHP:
\VxFramework\render_code().