Skip to main content

install_block

Function install_block 

Source
pub fn install_block(
    existing: &str,
    kind: HookKind,
    schema_version: u32,
) -> Result<String, HookError>
Expand description

Splice klasp’s managed block into existing, returning the new file body.

Behaviour matrix:

Input shapeOutput shape
empty / all-whitespace<shebang>\n\n<block> (fresh-create)
starts with a shebang, no block<existing>\n\n<block> (append after user content)
no shebang, no block<shebang>\n\n<existing>\n\n<block>
contains a managed blockblock contents replaced in-place

Idempotent: when the existing block already matches the rendered block byte-for-byte and no shebang prepending was needed, the input is returned unchanged.