nosDataReplace

$.nosDataReplace(object, data)

Replaces placeholder defined by the {{placeholder}} pattern in a string or JSON.

Arguments:
  • object (mixed) – A string or a JSON, where to search placeholder to replace.
  • data (JSON) – A JSON, placeholder => replacement value.
Returns:

Initial object with placeholders replaced.

$.nosDataReplace(obj, data);

$.nosDataReplace('exemple {{foo}}', {foo : 'bar'});
// returns 'exemple bar'

$.nosDataReplace({
        astring: 'example {{foo}}',
        json: {
                string: 'sample {{bar}}',
        }
},
{
        foo : 'bar',
        bar : 'foo'
});
//returns {
//      astring: 'example bar',
//      json: {
//              string: 'sample foo',
//}