web/assets/libs/seajs/seajs-text/1.1.1/seajs-text.js

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/**
 * The Sea.js plugin for loading text resources such as template, json etc
 */

var global = window
var plugins = {}
var uriCache = {}

function register(o) {
    plugins[o.name] = o
}

// normal text
register({
    name: "text",

    ext: [".tpl", ".html"],

    exec: function(uri, content) {
        globalEval('define("' + uri + '#", [], "' + jsEscape(content) + '")')
    }
})

// json
register({
    name: "json",

    ext: [".json"],

    exec: function(uri, content) {
        globalEval('define("' + uri + '#", [], ' + content + ')')
    }
})

// for handlebars template
register({
    name: "handlebars",

    ext: [".handlebars"],

    exec: function(uri, content) {
        var code = [
            'define("' + uri + '#", ["handlebars"], function(require, exports, module) {',
            '  var source = "' + jsEscape(content) + '"',
            '  var Handlebars = require("handlebars")["default"]',
            '  module.exports = function(data, options) {',
            '    options || (options = {})',
            '    options.helpers || (options.helpers = {})',
            '    for (var key in Handlebars.helpers) {',
            '      options.helpers[key] = options.helpers[key] || Handlebars.helpers[key]',
            '    }',
            '    return Handlebars.compile(source)(data, options)',
            '  }',
            '})'
        ].join('\n')

        globalEval(code)
    }
})

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。