{"version":3,"sources":["jsdelivr-header.js","/npm/koa-art-template@1.1.1/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,MAAQ,QAAQ,QAAR,CAAiB,gBACzB,SAAW,QAAQ,gBAGnB,gBAAkB,CACpB,MAAgC,eAAzB,QAAQ,IAAI,SACnB,WAAW,GAQf,QAAU,OAAO,QAAU,SAAU,EAAK,EAAW,CAAC,GAC9C,EAAI,QAAQ,SAIhB,EAAW,OAAO,OAAO,CAAC,EAAG,gBAAiB,GAU9C,EAAI,QAAQ,OAAS,SAAU,EAAM,GACjC,MAAM,EAAM,KACN,EAAU,OAAO,OAAO,CAAC,EAAG,EAAI,MAAO,GACvC,GAXgB,EAWI,EAV1B,MAAM,WADM,EAWQ,KATpB,EAAS,SAAW,EACL,SAAS,QAAQ,EACzB,CAAO,IAJlB,IAAgB,EAAU,EActB,MAFwC,IAAtB,EAAQ,YAA+B,EAAQ,WAAa,EAAS,YAMnF,OAAO,EAHP,EAAI,KAAO,OACX,EAAI,KAAO,CAKnB,EACJ,EAGA,QAAQ,SAAW","file":"/npm/koa-art-template@1.1.1/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/koa-art-template@1.1.1/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const debug = require('debug')('art-template');\nconst template = require('art-template');\n\n\nconst defaultSettings = {\n    debug: process.env.NODE_ENV !== 'production',\n    writeResp: true\n};\n\n/**\n * set app.context.render\n * @param {Application} app      koa application instance\n * @param {Object}      settings user settings\n */\nexports = module.exports = function (app, settings = {}) {\n    if (app.context.render) {\n        return;\n    }\n\n    settings = Object.assign({}, defaultSettings, settings);\n\n    function render(filename, data) {\n        debug(`render: ${filename}`);\n        settings.filename = filename;\n        const render = template.compile(settings);\n        return render(data);\n    }\n\n\n    app.context.render = function (view, _context) {\n        const ctx = this;\n        const context = Object.assign({}, ctx.state, _context);\n        const html = render(view, context);\n        const writeResp = context.writeResp === false ? false : (context.writeResp || settings.writeResp);\n\n        if (writeResp) {\n            ctx.type = 'html';\n            ctx.body = html;\n        } else {\n            return html;\n        }\n\n    };\n};\n\n\nexports.template = template;"]}