mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 23:54:12 -08:00
49 lines
1 KiB
JavaScript
49 lines
1 KiB
JavaScript
|
/*
|
||
|
* JavaScript Templates Runtime
|
||
|
* https://github.com/blueimp/JavaScript-Templates
|
||
|
*
|
||
|
* Copyright 2011, Sebastian Tschan
|
||
|
* https://blueimp.net
|
||
|
*
|
||
|
* Licensed under the MIT license:
|
||
|
* http://www.opensource.org/licenses/MIT
|
||
|
*/
|
||
|
|
||
|
/* global define */
|
||
|
|
||
|
;(function ($) {
|
||
|
'use strict'
|
||
|
var tmpl = function (id, data) {
|
||
|
var f = tmpl.cache[id]
|
||
|
return data ? f(data, tmpl) : function (data) {
|
||
|
return f(data, tmpl)
|
||
|
}
|
||
|
}
|
||
|
tmpl.cache = {}
|
||
|
tmpl.encReg = /[<>&"'\x00]/g // eslint-disable-line no-control-regex
|
||
|
tmpl.encMap = {
|
||
|
'<': '<',
|
||
|
'>': '>',
|
||
|
'&': '&',
|
||
|
'"': '"',
|
||
|
"'": '''
|
||
|
}
|
||
|
tmpl.encode = function (s) {
|
||
|
return (s == null ? '' : '' + s).replace(
|
||
|
tmpl.encReg,
|
||
|
function (c) {
|
||
|
return tmpl.encMap[c] || ''
|
||
|
}
|
||
|
)
|
||
|
}
|
||
|
if (typeof define === 'function' && define.amd) {
|
||
|
define(function () {
|
||
|
return tmpl
|
||
|
})
|
||
|
} else if (typeof module === 'object' && module.exports) {
|
||
|
module.exports = tmpl
|
||
|
} else {
|
||
|
$.tmpl = tmpl
|
||
|
}
|
||
|
}(this))
|