You can do this using a heredoc. e.g.
generate.sh
:
#!/bin/sh
#define parameters which are passed in.
PORT=$1
DOMAIN=$2
#define the template.
cat << EOF
This is my template.
Port is $PORT
Domain is $DOMAIN
EOF
Output:
$ generate.sh 8080 domain.example
This is my template.
Port is 8080
Domain is domain.example
or save it to a file:
$ generate.sh 8080 domain.example > result