# subst

## PURPOSE

TEMPLATE/SUBST Substitute a replacement field by its value

## SYNOPSIS

function [tpl, str] = subst(tpl,handle)

## DESCRIPTION

    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.

## CROSS-REFERENCE INFORMATION

This function calls:

- get TEMPLATE/GET Access data stored in a Template object
- loadtpl TEMPLATE/LOADTPL Read a template from file

This function is called by:

- parse TEMPLATE/PARSE Fill in replacement fields with the class properties

## SOURCE CODE

    0001 function [tpl, str] = subst(tpl,handle)
    0002 %TEMPLATE/SUBST Substitute a replacement field by its value
    0003 %  STR = SUBST(TPL,HANDLE) substitute all the known fields of variable HANDLE
    0004 %  in the template TPL.
    0005
    0006 %  Copyright (C) 2003 Guillaume Flandin <Guillaume@artefact.tk>
    0007 %  $Revision: 1.0 $Date: 2003/05/05 22:19:51 $
    0008
    0009 tpl = loadtpl(tpl,handle);
    0010
    0011 str = get(tpl,'var',handle);
    0012 for i=1:length(tpl.varkeys)
    0013     str = strrep(str, strcat('{',tpl.varkeys{i},'}'), tpl.varvals{i});
    0014 end