mirror of
https://github.com/Xevion/dotfiles.git
synced 2025-12-06 01:14:48 -06:00
docs: improve template system documentation with context parameter clarification
- Distinguish between regular templates and partials for variable access - Document how partials receive context via explicit parameters - Add examples for both template types with correct syntax - Templatize global CLAUDE.md for platform-specific shell environment sections - Add conditional rendering for Windows, WSL, and Linux environments
This commit is contained in:
13
CLAUDE.md
13
CLAUDE.md
@@ -20,7 +20,14 @@ This is a **chezmoi source directory** for managing dotfiles across multiple mac
|
||||
|
||||
**Template System:**
|
||||
- Uses Go templates with platform detection
|
||||
- Variables: `.chezmoi.os`, `.chezmoi.homeDir`, `.data.*`
|
||||
- Two types of templates with different variable access patterns:
|
||||
- **Regular templates** (e.g., `home/dot_bashrc.tmpl`): Direct access to Chezmoi context
|
||||
- Built-in: `.chezmoi.os`, `.chezmoi.homeDir`
|
||||
- Custom data: `.wsl`, `.chassis`
|
||||
- **Partials** (reusable templates in `home/.chezmoitemplates/`): Must receive context via explicit parameter
|
||||
- Partials don't have automatic access to Chezmoi's context
|
||||
- Context passed as parameter (commonly `data`) when calling the partial
|
||||
- Access everything through parameter: `.data.chezmoi.os`, `.data.wsl`, `.data.chassis`
|
||||
- Conditional rendering for Windows/Linux/macOS/WSL
|
||||
|
||||
**Secret Management:**
|
||||
@@ -82,9 +89,11 @@ This is a **chezmoi source directory** for managing dotfiles across multiple mac
|
||||
- `chezmoi status` - see what's changed
|
||||
|
||||
4. **Use templates correctly**
|
||||
- Platform detection: `.chezmoi.os`, `.data.wsl`, `.data.chassis`
|
||||
- Platform detection in regular templates: `.chezmoi.os`, `.wsl`, `.chassis`
|
||||
- Platform detection in partials: `.data.chezmoi.os`, `.data.wsl`, `.data.chassis`
|
||||
- Doppler secrets: `{{ dopplerProjectJson.SECRET_NAME }}`
|
||||
- Conditional logic: `{{ if }}...{{ else }}...{{ end }}`
|
||||
- Example partial call: `{{ template "commonrc.sh.tmpl" . }}` (passes entire context as `data`)
|
||||
|
||||
5. **Suggest TODO list updates** (but DO NOT modify automatically)
|
||||
- When a task is completed, check if `TODO.md` exists in the repository
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
**Note**: Project-specific CLAUDE.md files take precedence for project-specific patterns.
|
||||
**Note**: Project-specific CLAUDE.md files take precedence for project-specific patterns.
|
||||
|
||||
{{- if and (eq .chezmoi.os "windows") (not .wsl) }}
|
||||
|
||||
## Shell Environment (Windows)
|
||||
|
||||
@@ -7,6 +9,25 @@
|
||||
- ❌ Do NOT use CMD commands (`dir`, `copy`, `del`)
|
||||
- ✅ Use standard Bash/Unix commands (`ls`, `cp`, `mv`, `rm`, `grep`)
|
||||
- Prefer relative paths for simplicity
|
||||
{{- else if .wsl }}
|
||||
|
||||
## Shell Environment (WSL)
|
||||
|
||||
- **You are in WSL (Windows Subsystem for Linux)**
|
||||
- ✅ Use standard Linux/Bash commands (`ls`, `cp`, `mv`, `rm`, `grep`)
|
||||
- ✅ Full access to Linux tooling and package managers
|
||||
- ⚠️ Can access Windows filesystem via `/mnt/c/`, but prefer Linux paths
|
||||
- ⚠️ Can call Windows executables (`.exe`), but prefer native Linux tools
|
||||
- Prefer relative paths for simplicity
|
||||
{{- else if eq .chezmoi.os "linux" }}
|
||||
|
||||
## Shell Environment (Linux)
|
||||
|
||||
- **You are in a standard Linux environment**
|
||||
- ✅ Use standard Bash/Unix commands (`ls`, `cp`, `mv`, `rm`, `grep`)
|
||||
- ✅ Full access to Linux tooling and package managers
|
||||
- Prefer relative paths for simplicity
|
||||
{{- end }}
|
||||
|
||||
## Build & Package Management
|
||||
|
||||
Reference in New Issue
Block a user