def template_substitute(text, **kwargs):
 for (name, value) in kwargs.items():
  placeholder_pattern = ('{%s}' % name)
  if (placeholder_pattern in text):
   text = text.replace(placeholder_pattern, value)
 return text

def template_substitute ( text , ** kwargs ) : for ( name , value ) in kwargs . items ( ) : placeholder_pattern = ( '{%s}' % name ) if ( placeholder_pattern in text ) : text = text . replace ( placeholder_pattern , value ) return text
replace placeholders in text by using the data mapping .