开发者

Is there any wide-known "standard syntax" for placeholders in literal content that I could use?

I'm coding a program that among other things reads a lot of settings from an external text-file. Within the settings it is possible to use placeholders, for example:

<setting key="NAME" value="Ozzy"/>
<setting key="WELCOME_MESSAGE" value="Welcome, ${NAME}!"/>

As you probably have guessed, the program should inject the value of the setting NAME into the placeholder ${NAME} so that the resulting value of WELCOME_MESSAGE becomes "Welcome, Ozzy!".开发者_运维技巧 Nothing advanced with that (i'm not asking for code/regular expression help here ;))

My question is rather if there are any existing wide-known "standard syntax" for how placeholders like this are usually written?? Ofcourse it's very easy to invent my own "syntax" for it (like I did above)....but I kind of like to complicate things sometimes.

So, if no such "standard" exists (have a feeling it doesn't), what are your suggestions of a good syntax? Some "requirements":

  • Easy to parse.
  • VERY unlikely to collide with other literal content.
  • Should not cause the XML to be corrupt.
  • Is easy to use and understand for non-programmers, i.e. not look too "geeky" ;)


There is no standard.

You're syntax is similar to existing implementations. For example, SalesForce.com (used by non-geeks) uses {!variable}.

Don't forget about formatting and localization --especially for numbers and dates.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜