* Returns the content for a specific type (section) for index.html. * * ``` * {{content-for "[type]"}} * ``` * * Supported types: * * - 'head' * - 'config-module' * - 'head-footer' * - 'test-header-footer' * - 'body-footer' * - 'test-body-footer' * * @method contentFor * @param {Obje
(config, match, type, options)
| 63 | * @return {String} The content. |
| 64 | */ |
| 65 | function contentFor(config, match, type, options) { |
| 66 | let content = []; |
| 67 | |
| 68 | // This normalizes `rootURL` to the value which we use everywhere inside of Ember CLI. |
| 69 | // This makes sure that the user doesn't have to account for it in application code. |
| 70 | if ('rootURL' in config) { |
| 71 | config.rootURL = normalizeUrl(config.rootURL); |
| 72 | } |
| 73 | |
| 74 | switch (type) { |
| 75 | case 'head': |
| 76 | if (options.storeConfigInMeta) { |
| 77 | content.push( |
| 78 | `<meta name="${config.modulePrefix}/config/environment" content="${encodeURIComponent( |
| 79 | JSON.stringify(config) |
| 80 | )}" />` |
| 81 | ); |
| 82 | } |
| 83 | |
| 84 | break; |
| 85 | case 'config-module': |
| 86 | if (options.storeConfigInMeta) { |
| 87 | content.push(`var prefix = '${config.modulePrefix}';`); |
| 88 | content.push(fs.readFileSync(path.join(__dirname, '../broccoli/app-config-from-meta.js'))); |
| 89 | } else { |
| 90 | content.push(` |
| 91 | var exports = { |
| 92 | 'default': ${JSON.stringify(config)} |
| 93 | }; |
| 94 | Object.defineProperty(exports, '__esModule', {value: true}); |
| 95 | return exports; |
| 96 | `); |
| 97 | } |
| 98 | |
| 99 | break; |
| 100 | case 'app-boot': |
| 101 | if (options.autoRun) { |
| 102 | let moduleToRequire = `${config.modulePrefix}/app`; |
| 103 | content.push(` |
| 104 | if (!runningTests) { |
| 105 | require("${moduleToRequire}")["default"].create(${convertObjectToString(config.APP)}); |
| 106 | } |
| 107 | `); |
| 108 | } |
| 109 | |
| 110 | break; |
| 111 | case 'test-body-footer': |
| 112 | content.push( |
| 113 | `<script> |
| 114 | document.addEventListener('DOMContentLoaded', function() { |
| 115 | if (!EmberENV.TESTS_FILE_LOADED) { |
| 116 | throw new Error('The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".'); |
| 117 | } |
| 118 | }); |
| 119 | </script>` |
| 120 | ); |
| 121 | |
| 122 | break; |
no test coverage detected
searching dependent graphs…