Resolve relative to file path in shortcodes

I wanted a shortcode that would

  1. include and highlight code from a file,

  2. provide a link to the same file.

The syntax ended up being

{{< inclsrc "julia" "code.jl" >}}

where the first argument specifies the language, the second the path, which is meant to be resolved relative to the current file.

After reading relevant sections of the manual, I came up with

{{ $file_param := (.Get 1) }}
{{ $file := (printf "%s%s" $.Page.File.Dir $file_param) }}
{{ highlight (readFile (printf "content/%s" $file)) (.Get 0) ""}}
<div class="getcode"><p>(download the above as <a href="{{ absURL $file }}">{{ $file_param }}</a>)</div>

which works, but I am wondering if there is a way to handle those paths more elegantly. All those printfs look kludgy.