Q:

Convert a Filepath string into a Filepath/Directory in Bash

I'm trying to make a simple script that creates files from some plain/text templates. 
In detail, the script parses and replaces the content of some files using sed and takes the filepath where the generated file should be written, from the template itself using awk. 
Unfortunately, the filepath taken with awk is a string, so when I use the redirection operator ">" to write the sed output to the filepath variable, the shell gives me this error:
./script.sh: line 45: ~/path/to/file/generatedFile: No such file or directory

Some script code
// CSDdir:~/path/to/file/generatedFile

* {
    margin:                     0;
    spacing:                    0;
    border:                     0;
    text-color:                 <fg>;
    background-color:           transparent;
    border-color:               <bg>;
...

first lines of a template. 

...

# Dirs
CUR_DIR=$( dirname "$(readlink -f "$0")" )
TEMPLATES_DIR="$CUR_DIR/templates"

...

tempDir=$( awk -F':' '$1 == "// CSDdir" { print $2; exit }' "$TEMPLATES_DIR/templateFile" )

cat "$TEMPLATES_DIR/templateFile" | sed \ # this is line 45
-e "s/<font>/$font/g" \
-e "s/<fg>/$foreground/g" \
-e "s/<bg>/$background/g" \
-e "s/<color0>/$color0/g" \
-e "s/<color8>/$color8/g" \
-e "s/<color1>/$color1/g" \
-e "s/<color9>/$color9/g" \
-e "s/<color2>/$color2/g" \
-e "s/<color10>/$color10/g" \
-e "s/<color3>/$color3/g" \
-e "s/<color11>/$color11/g" \
-e "s/<color4>/$color4/g" \
-e "s/<color12>/$color12/g" \
-e "s/<color5>/$color5/g" \
-e "s/<color13>/$color13/g" \
-e "s/<color6>/$color6/g" \
-e "s/<color14>/$color14/g" \
-e "s/<color7>/$color7/g" \
-e "s/<color15>/$color15/g" \
> $tempDir 

awk takes the filepath from templateFile and put it in tempDir. 
sed substitute "tags" with values and write the output in tempDir filepath, but it gives me the error mentioned before. 
Is there a way to convert the content of tempDir into a filepath / directory? 
or, is there a way to do the same thing but with other methods? 

A:

Thanks to @chepner, I found a solution by myself. 
The problem was the ~ character that when taken by awk, it doesn't "expand" to home directory.   
The cleaner way to solve that is to replace the ~ (if it's present) in tempDir with $HOME value and \ character:
home=$( echo $HOME | sed 's/\//\\\//g')
tempDir=$( awk -F':' '$1 == "// CSDdir" { print $2; exit }' "$TEMPLATES_DIR/rofiConfig" | sed -e "s/~/$home/g" )

Now, all perfectly works.