How to use the sprintf function from underscore.string

Find comprehensive JavaScript underscore.string.sprintf code examples handpicked from public code repositorys.

43
44
45
46
47
48
49
50
51
52
    let query, queryString, orderBy;
    options = options ? options : {}; 
    options.fields = options.fields ? options.fields : ["id", "key", "summary", "status", "priority", "assignee", "duedate", "resolutiondate", "issuetype"];
    query = _.isObject(args) ? this.parseFilterParams(args) : args;
    orderBy = args.order && args.order.orderBy ? "order by " + (this.parseOrderParams(args.order)): "";
    queryString = _s.sprintf("%s %s", query, orderBy);
    return super.searchJira(queryString, options);
}

parseFilterParams(args) {
fork icon1
star icon0
watch icon0

58
59
60
61
62
63
64
65
66
67
// string.
module.exports.list2d = function( ls ) {
    var fmt = '%-' + _u.max( _u.map( ls, _u.size )) + 2 + 's';
    var fn = function( memo, value, key ) {
        line = (memo.length + value.length + 2) < 80
                    ?  _u.last( memo ) + _s.sprintf( fmt, value )
                    : _s.sprintf( fmt, value );
        memo[ memo.length-1 ] = line;
        return memo;
    }
fork icon0
star icon2
watch icon2

+ 3 other calls in file

229
230
231
232
233
234
235
236
237
238
239
240
    return _s.sprintf('<p><a href="%s">Click Here</a> for details</p>', link);
}


function genSlackLink(ticket) {
    var link = genAdminTicketLink(ticket);
    return _s.sprintf('\n<%s|Click here for detail! >', link);
}


function sendEmail(ticket, subject, text, email) {
    var type = ticket.get('type');
fork icon0
star icon0
watch icon2

+ 3 other calls in file

61
62
63
64
65
66
67
68
69
70
},
function(userObj, done) {
  var enml_format = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>%s</en-note>';
  var note = {
    title: title,
    content: _.sprintf(enml_format, content),
    created: new Date().getTime(),
    contentLength: content.length
  }
  var noteType = new everType.Note(note);
fork icon0
star icon0
watch icon0

29
30
31
32
33
34
35
36
37
38

$ctrl.applyProduct = () => {
    if(vouchers.length == 1){
        let voucher = vouchers[0];

        let popupTitle = _string.sprintf(
            $filter('translate')('product_apply.popup.title'),
            $ctrl.product.name,
            $ctrl.product.expire_at,
            $ctrl.product.price
fork icon0
star icon0
watch icon0