Aller au contenu

Theme functions

Ce contenu n’est pas encore disponible dans votre langue.

The theme functions are a way to customize the look and add some logic to your CV Theme. You can use them in your theme template to help you display the content of your CV.

The inc function is used to increment a number. It can also be used to get the next item of a list.

Code Output
{{ inc 5 }} 6
{{ inc 0 }} 1
{{ inc $length }} $length + 1

The dec function is used to decrement a number. It can also be used to get the last item of a list.

Code Output
{{ dec 5 }} 4
{{ dec 0 }} -1
{{ dec $length }} $length - 1

The list function is used to create a list of items.

Code Output
{{ list 1 2 3 }} [1 2 3]
{{ list "a" "b" "c" }} [a b c]
{{ list "CV" "Wonder" }} [CV Wonder]

The join function is used to concatenate a list of strings without or with a separator.

Code Output
{{ join (list "CV" "Wonder") "" }} CVWonder
{{ join (list "CV" "Wonder") " " }} CV Wonder
{{ join (list "a" "b" "c") " " }} a b c
{{ join (list "1" "2" "3") "-" }} 1-2-3

The split function is used to split a string into a list of substrings.

Code Output
{{ split "CV Wonder" " " }} [CV Wonder]
{{ split "CV-Wonder" "-" }} [CV Wonder]
{{ split "1-2-3" "-" }} [1 2 3]

trim - Remove leading/trailing whitespaces

Section titled “trim - Remove leading/trailing whitespaces”

The trim function is used to remove leading and trailing whitespace from a string.

Code Output
{{ trim " CV Wonder " }} CV Wonder
{{ trim " CV Wonder " }} CV Wonder
{{ trim " CV Wonder " }} CV Wonder

The lower function is used to convert a string to lowercase.

Code Output
{{ lower "CV Wonder" }} cv wonder
{{ lower "CVWONDER" }} cvwonder
{{ lower "cv wonder" }} cv wonder

The upper function is used to convert a string to uppercase.

Code Output
{{ upper "CV Wonder" }} CV WONDER
{{ upper "cvwonder" }} CVWONDER
{{ upper "cv wonder" }} CV WONDER
{{ upper "CV WONDER" }} CV WONDER

The replace function is used to replace a substring in a string.

Code Output
{{ replace "Hello World" "World" "CV Wonder" }} Hello CV Wonder
{{ replace "Hello World" "World" "" }} Hello

The odd function is used to check if a number is odd.

Code Output
{{ odd 1 }} true
{{ odd 2 }} false
{{ odd 3 }} true

The even function is used to check if a number is even.

Code Output
{{ even 1 }} false
{{ even 2 }} true
{{ even 3 }} false

The add function is used to add two numbers.

Code Output
{{ add 1 2 }} 3
{{ add 2 3 }} 5
{{ add 10 2 }} 12

The sub function is used to subtract two numbers.

Code Output
{{ sub 1 2 }} -1
{{ sub 2 3 }} -1
{{ sub 10 2 }} 8

The qrCode function generates a QR code from a URL and returns an HTML <img> tag with the image embedded as a PNG base64 data URI. The QR code is produced at render time — no network requests, no external files. It works in both HTML and PDF output.

Returns an empty string when url is empty, so it is safe to call directly against model fields.

Signature:

{{ qrCode <url> [options...] }}

Options are "key=value" strings passed after the URL:

Option Description Default Values
size Pixels per QR cell 5 Integer (1–255)
fg Foreground (module) color #000000 Hex color (#RRGGBB)
bg Background color #ffffff Hex color (#RRGGBB)
ec Error correction level M L (7%) / M (15%) / Q (25%) / H (30%)
Code Description
{{ qrCode .Person.Site }} QR code with all defaults
{{ qrCode .Person.Site "size=6" }} Larger cells
{{ qrCode .Person.Site "fg=#0077b5" }} Blue modules (LinkedIn brand color)
{{ qrCode .Person.Site "bg=#f5f5f5" }} Light grey background
{{ qrCode .Person.Site "ec=H" }} Highest error correction (30%)

Typical usage in a theme:

{{/* Portfolio QR code in the header — only shown when a site URL is set */}}
{{ if .Person.Site }}
<div class="qr-contact">
{{ qrCode .Person.Site "size=5" "fg=#333333" }}
<span>Portfolio</span>
</div>
{{ end }}
{{/* LinkedIn QR code with brand color in the sidebar */}}
{{ if .SocialNetworks.Linkedin }}
{{ qrCode (printf "https://linkedin.com/in/%s" .SocialNetworks.Linkedin) "size=5" "fg=#0077b5" }}
{{ end }}
{{/* High error correction for a small QR in a logo-heavy layout */}}
{{ qrCode .Person.Site "size=4" "fg=#222222" "ec=H" }}

If you need a function that is not available in CV Wonder, you can ask us to add it on Github Issues. We will be happy to help you.