Logging Helpers
Table of Contents
logging
Note: These helpers are only available in Node.js environments. They are not compatible with browser-based Handlebars usage.
These helpers output messages to the terminal with ANSI color formatting. All logging helpers return an empty string to avoid affecting template output.
{{log}}
Logs an unstyled message to the terminal via console.log.
Params
...args{any}: Values to logreturns{String}: Empty string
Example
{{log "Processing item:" itemName}}
{{ok}}
Logs a green colored message preceded by a checkmark to the terminal. Useful for indicating successful operations.
Params
...args{any}: Values to log (will be joined with spaces)returns{String}: Empty string
Example
{{ok "Build completed successfully"}}
{{success}}
Logs a green colored message to the terminal. Similar to ok but without the checkmark.
Params
...args{any}: Values to log (will be joined with spaces)returns{String}: Empty string
Example
{{success "All tests passed"}}
{{info}}
Logs a cyan colored informational message to the terminal.
Params
...args{any}: Values to log (will be joined with spaces)returns{String}: Empty string
Example
{{info "Processing" totalCount "items"}}
{{warning}}
Logs a yellow colored warning message to stderr.
Params
...args{any}: Values to log (will be joined with spaces)returns{String}: Empty string
Example
{{warning "Deprecated feature detected"}}
{{warn}}
Alias for {{warning}}. Logs a yellow colored warning message to stderr.
Params
...args{any}: Values to log (will be joined with spaces)returns{String}: Empty string
Example
{{warn "This method will be removed in v5"}}
{{error}}
Logs a red colored error message to stderr.
Params
...args{any}: Values to log (will be joined with spaces)returns{String}: Empty string
Example
{{error "Failed to process item:" itemId}}
{{danger}}
Alias for {{error}}. Logs a red colored error message to stderr.
Params
...args{any}: Values to log (will be joined with spaces)returns{String}: Empty string
Example
{{danger "Critical failure in module"}}
{{bold}}
Logs a bold formatted message to stderr.
Params
...args{any}: Values to log (will be joined with spaces)returns{String}: Empty string
Example
{{bold "Important Notice"}}
{{_debug}}
Outputs debug information including the provided value and the current Handlebars context. Useful for inspecting template data during development.
Params
...args{any}: Optional values to inspectreturns{String}: Empty string
Example
{{_debug user}}
{{_inspect}}
Formats a value as JSON and returns it for display in the template. Supports different output formats.
Params
context{any}: The value to inspectoptions.hash.type{String}: Output format:"html"(default),"md", or any other value for raw JSONreturns{String}: Formatted JSON string
Example
{{_inspect user}}
{{_inspect user type="md"}}
{{_inspect user type="raw"}}