HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_new/buyercall/buyercall/assets/scripts/vendor/html_utils.js
// A collection of functions to simplify Underscore template building

var _ = require('underscore');

var utils = {
    /** Builds the HTML for a series of <option> elements.
     *
     * vals - An array of parameters, in the format [[value, text], [value, text],.. ]
     * selectedVal - The value of the <option> to be marked as selected.
     */
    options: function (vals, selectedVal) {
        var text = [];
        vals.forEach(function (val, i) {
            text.push('<option value="', _.escape(val[0]), '"',
              ((val[0] == selectedVal) ? " selected" : ""), '>',
              _.escape(val[1]), '</option>');
        });
        return text.join('');
    }
};

module.exports = utils;