ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

FormatVar

Like format type. Source: https://www.extensionmethod.net/csharp/string/withvar

Source

String.prototype.FormatVar = function () {
let ret = this.trim(), stf = arguments[0] || {};
for (key in stf) { ret = ret.replaceAll('{' + key + '}', String(stf[key])); }
return ret;
};

Example

var abc = {Syf: 'Sayfa', Yst: 'YoksisTip', Add:'AddUser', Addv:1 };
var sff = 'SELECT * FROM dbo.{Syf} AS S WITH (NOLOCK) WHERE (S.{Yst} IS NOT NULL) AND S.{Add} = {Addv}';
var ret = sff.FormatVar(abc);

Author: Uğur Demirel

Submitted on: 28 jan. 2021

Language: javascript

Type: String

Views: 3796