Home Documentation Templates Examples Showcase GitHub
Theme

Scripting · Script land

Native Nift scripting.

Nift 4.3 has two deliberately distinct contexts: template land for building websites, and script land for native statements, reusable script files and interactive automation. They share one Nift language/runtime rather than embedding another interpreter.

Template land vs script land

ContextPurposeSyntax
Template landGenerate pages and other tracked output@if, @for, $[...], @input
Script landExecute native Nift statementsif, for, fn, assignments and ordinary calls

@script { ... } is the explicit bridge from a template into script land. Inside it, ordinary statements do not need $[...] wrappers and language constructs do not need template @ prefixes.

@script {
    values := [1, 2, 3, 4]
    doubled := values.map(x => x * 2)

    if(doubled.contains(8)) {
        return doubled.join(", ")
    }

    return
}

An inline script executes in the current template scope. Falling through or using bare return emits nothing; return expression renders exactly that value. Returned strings are values and are not reparsed as template source.

Script files and interactive use

Use @import(path) for isolated reusable script files, nift run and nift sh for standalone execution, and the dedicated filesystem and stream references for script-side I/O.

No shell escape.

Native scripting does not resurrect @system or arbitrary subprocess execution. Script land stays inside Nift's own runtime and capability boundaries.