#!/usr/bin/env bash ############################################################## # Jinja2 Template Renderer - Ninja Edition # A sophisticated template rendering engine with style ############################################################## set -uo pipefail # Note: Using -u and pipefail, but not -e to allow graceful error handling # Terminal colors using tput BLACK="" RED="" GREEN="" YELLOW="" BLUE="" MAGENTA="" CYAN="" WHITE="" GRAY="" BOLD="" DIM="" ITALIC="" UNDERLINE="" RESET="" if [[ -t 1 ]] && command -v tput >/dev/null 2>&1; then COLORS=$(tput colors 2>/dev/null || echo 0) if [[ ${COLORS:-0} -ge 8 ]]; then BLACK=$(tput setaf 0 2>/dev/null || echo "") RED=$(tput setaf 1 2>/dev/null || echo "") GREEN=$(tput setaf 2 2>/dev/null || echo "") YELLOW=$(tput setaf 3 2>/dev/null || echo "") BLUE=$(tput setaf 4 2>/dev/null || echo "") MAGENTA=$(tput setaf 5 2>/dev/null || echo "") CYAN=$(tput setaf 6 2>/dev/null || echo "") WHITE=$(tput setaf 7 2>/dev/null || echo "") GRAY=$(tput setaf 8 2>/dev/null || echo "") BOLD=$(tput bold 2>/dev/null || echo "") DIM=$(tput dim 2>/dev/null || echo "") ITALIC=$(tput sitm 2>/dev/null || echo "") UNDERLINE=$(tput smul 2>/dev/null || echo "") RESET=$(tput sgr0 2>/dev/null || echo "") fi fi # Ninja-themed icons (ASCII compatible) readonly NINJA="[NINJA]" readonly SHURIKEN="*" readonly KATANA=">>" readonly SCROLL="[SCROLL]" readonly FIRE="[FIRE]" readonly STAR="*" readonly CHECK="[OK]" readonly CROSS="[X]" readonly ARROW="-->" readonly LIGHTNING="[!]" readonly GEAR="[GEAR]" readonly TARGET="[TARGET]" # Script configuration OUTPUT_DIR="${PWD}/output" TEMPLATES=() VAR_FILES=() CLI_VARS=() VERBOSE=false PREVIEW=false WATCH=false STRICT=false DRY_RUN=false # Performance tracking START_TIME=0 TEMPLATE_COUNT=0 VAR_COUNT=0 ############################################################## # Ninja UI Functions ############################################################## print_ninja_banner() { echo "${MAGENTA}${BOLD}" cat << 'EOF' TPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPW Q Q Q � JINJA2 TEMPLATE RENDERER - NINJA EDITION Q Q Q Q >w Fast " Powerful " Stealthy Template Magic � Q Q Q ZPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP] EOF echo "${RESET}" } print_ninja_art() { echo "${CYAN}${DIM}" cat << 'EOF' ___ __/_ `. .-"""-. \_,` | \-' / )`-') "") `"` \ ((`"` ___Y , .'7 /| (_,___/...-` (_/_/ Silently rendering your templates... EOF echo "${RESET}" } # Animated ninja message ninja_say() { local message="$1" echo "${CYAN}${NINJA}${RESET} ${BOLD}${message}${RESET}" } ninja_success() { echo "${GREEN}${CHECK} ${NINJA}${RESET} ${GREEN}$*${RESET}" } ninja_error() { echo "${RED}${CROSS} ${NINJA}${RESET} ${RED}$*${RESET}" >&2 } ninja_warn() { echo "${YELLOW}${LIGHTNING}${RESET} ${YELLOW}$*${RESET}" } ninja_info() { echo "${BLUE}${SHURIKEN}${RESET} ${BLUE}$*${RESET}" } ninja_verbose() { [[ "$VERBOSE" == true ]] && echo "${DIM} ${ARROW} $*${RESET}" } ninja_progress() { local current=$1 local total=$2 local item=$3 local percent=$((current * 100 / total)) local bar_length=30 local filled=$((bar_length * current / total)) local bar="" for ((i=0; i [template...] ${BOLD}DESCRIPTION:${RESET} A sophisticated Jinja2 template rendering engine with support for multiple variable sources, glob patterns, and ninja-style operations. ${BOLD}ARGUMENTS:${RESET}