Skip to content

Less is more - using a global variable to define a function/handler - is this possible? #4177

Answered by twpayne
arrrgi asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can use includeTemplate for this:

  1. Create a file called hcpHandler in a .chezmoitemplates containing:

    {{ (output "hcp" "vs" "s" "open" "--format" "json" "--app" "app-chezmoi" . | fromJson).static_version.value }}
    
  2. Call this using includeTemplate, for example:

    [GDrive]
    type = drive
    client_id = {{ includeTemplate "hcpHandler" "rcloneDriveId" }}
    

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@halostatue
Comment options

@arrrgi
Comment options

@arrrgi
Comment options

@halostatue
Comment options

@arrrgi
Comment options

Answer selected by halostatue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants