text "variables"

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi

sorry, this doesn't really have anything to do with c#, but I wasn't
sure where else to post.

I am writing some code which needs to parse some text (a string) which
is to contain "variables" (special tags) which should be replaced with
real values.

For example, a variable called "CURRENT_DATE" or "USER_NAME".

Is there any standard or best-practice for the syntax for this sort of
thing?

Like "As of today {%CURRENT_DATE%} your username {%USER_NAME%} is
suspended..."


Thanks,
Peter


--
 
I did something similar for generating email messages from a website. I
just did something like this


string RenderMessage(string viewName, Dictionary<string, string> values)
{
string text = (load it from file using viewName);
foreach(KeyValuePair<string, string> kvp in values)
text = text.Replace("{%" + kvp.Key + "%}", kvp.Value);
return text;
}
 
Back
Top