You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: subst.m
    path of file: ./repos/HOG-Pedestrian-Detector/libs/m2html/@template/private
    
    the code of the file until where you have to start completion: function [tpl, str] = subst(tpl,handle)
%TEMPLATE/SUBST Substitute a replacement field by its value
%  STR = SUBST(TPL,HANDLE) substitute all the known fields of variable HANDLE
%  in the template TPL.

%  Copyright (C) 2003 Guillaume Flandin <Guillaume@artefact.tk>
%  $Revision: 1.0 $Date: 2003/05/05 22:19:51 $


    
function [tpl, str] = subst(tpl,handle)
%TEMPLATE/SUBST Substitute a replacement field by its value
%  STR = SUBST(TPL,HANDLE) substitute all the known fields of variable HANDLE
%  in the template TPL.

%  Copyright (C) 2003 Guillaume Flandin <Guillaume@artefact.tk>
%  $Revision: 1.0 $Date: 2003/05/05 22:19:51 $

tpl = loadtpl(tpl,handle);

str = get(tpl,'var',handle);
for i=1:length(tpl.varkeys)
	str = strrep(str, strcat('{',tpl.varkeys{i},'}'), tpl.varvals{i});
end