mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Use ...spread elements instead of [].concat in boilerplate templates.
This commit is contained in:
@@ -6,29 +6,26 @@ export const headTemplate = ({
|
||||
bundledJsCssUrlRewriteHook,
|
||||
head,
|
||||
dynamicHead,
|
||||
}) => [].concat(
|
||||
[
|
||||
'<html' + Object.keys(htmlAttributes || {}).map(key =>
|
||||
template(' <%= attrName %>="<%- attrValue %>"')({
|
||||
attrName: key,
|
||||
attrValue: htmlAttributes[key]
|
||||
})
|
||||
).join('') + '>',
|
||||
'<head>'
|
||||
],
|
||||
}) => [
|
||||
'<html' + Object.keys(htmlAttributes || {}).map(
|
||||
key => template(' <%= attrName %>="<%- attrValue %>"')({
|
||||
attrName: key,
|
||||
attrValue: htmlAttributes[key],
|
||||
})
|
||||
).join('') + '>',
|
||||
'<head>',
|
||||
|
||||
(css || []).map(({ url }) =>
|
||||
...(css || []).map(file =>
|
||||
template(' <link rel="stylesheet" type="text/css" class="__meteor-css__" href="<%- href %>">')({
|
||||
href: bundledJsCssUrlRewriteHook(url)
|
||||
href: bundledJsCssUrlRewriteHook(file.url),
|
||||
})
|
||||
),
|
||||
[
|
||||
head,
|
||||
dynamicHead,
|
||||
'</head>',
|
||||
'<body>',
|
||||
],
|
||||
).join('\n')
|
||||
|
||||
head,
|
||||
dynamicHead,
|
||||
'</head>',
|
||||
'<body>',
|
||||
].join('\n');
|
||||
|
||||
// Template function for rendering the boilerplate html for browsers
|
||||
export const closeTemplate = ({
|
||||
@@ -38,39 +35,35 @@ export const closeTemplate = ({
|
||||
js,
|
||||
additionalStaticJs,
|
||||
bundledJsCssUrlRewriteHook,
|
||||
}) => [].concat(
|
||||
[
|
||||
'',
|
||||
(inlineScriptsAllowed
|
||||
? template(' <script type="text/javascript">__meteor_runtime_config__ = JSON.parse(decodeURIComponent(<%= conf %>))</script>')({
|
||||
conf: meteorRuntimeConfig
|
||||
})
|
||||
: template(' <script type="text/javascript" src="<%- src %>/meteor_runtime_config.js"></script>')({
|
||||
src: rootUrlPathPrefix
|
||||
})
|
||||
) ,
|
||||
''
|
||||
],
|
||||
}) => [
|
||||
'',
|
||||
inlineScriptsAllowed
|
||||
? template(' <script type="text/javascript">__meteor_runtime_config__ = JSON.parse(decodeURIComponent(<%= conf %>))</script>')({
|
||||
conf: meteorRuntimeConfig,
|
||||
})
|
||||
: template(' <script type="text/javascript" src="<%- src %>/meteor_runtime_config.js"></script>')({
|
||||
src: rootUrlPathPrefix,
|
||||
}),
|
||||
'',
|
||||
|
||||
(js || []).map(({ url }) =>
|
||||
...(js || []).map(file =>
|
||||
template(' <script type="text/javascript" src="<%- src %>"></script>')({
|
||||
src: bundledJsCssUrlRewriteHook(url)
|
||||
src: bundledJsCssUrlRewriteHook(file.url),
|
||||
})
|
||||
),
|
||||
|
||||
(additionalStaticJs || []).map(({ contents, pathname }) => (
|
||||
(inlineScriptsAllowed
|
||||
...(additionalStaticJs || []).map(({ contents, pathname }) => (
|
||||
inlineScriptsAllowed
|
||||
? template(' <script><%= contents %></script>')({
|
||||
contents: contents
|
||||
contents,
|
||||
})
|
||||
: template(' <script type="text/javascript" src="<%- src %>"></script>')({
|
||||
src: rootUrlPathPrefix + pathname
|
||||
}))
|
||||
src: rootUrlPathPrefix + pathname,
|
||||
})
|
||||
)),
|
||||
|
||||
[
|
||||
'', '',
|
||||
'</body>',
|
||||
'</html>'
|
||||
],
|
||||
).join('\n');
|
||||
'',
|
||||
'',
|
||||
'</body>',
|
||||
'</html>'
|
||||
].join('\n');
|
||||
|
||||
@@ -12,64 +12,61 @@ export const headTemplate = ({
|
||||
bundledJsCssUrlRewriteHook,
|
||||
head,
|
||||
dynamicHead,
|
||||
}) => [].concat(
|
||||
[
|
||||
'<html>',
|
||||
'<head>',
|
||||
' <meta charset="utf-8">',
|
||||
' <meta name="format-detection" content="telephone=no">',
|
||||
' <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, viewport-fit=cover">',
|
||||
' <meta name="msapplication-tap-highlight" content="no">',
|
||||
' <meta http-equiv="Content-Security-Policy" content="default-src * gap: data: blob: \'unsafe-inline\' \'unsafe-eval\' ws: wss:;">',
|
||||
],
|
||||
}) => [
|
||||
'<html>',
|
||||
'<head>',
|
||||
' <meta charset="utf-8">',
|
||||
' <meta name="format-detection" content="telephone=no">',
|
||||
' <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, viewport-fit=cover">',
|
||||
' <meta name="msapplication-tap-highlight" content="no">',
|
||||
' <meta http-equiv="Content-Security-Policy" content="default-src * gap: data: blob: \'unsafe-inline\' \'unsafe-eval\' ws: wss:;">',
|
||||
|
||||
// We are explicitly not using bundledJsCssUrlRewriteHook: in cordova we serve assets up directly from disk, so rewriting the URL does not make sense
|
||||
(css || []).map(({ url }) =>
|
||||
...(css || []).map(file =>
|
||||
template(' <link rel="stylesheet" type="text/css" class="__meteor-css__" href="<%- href %>">')({
|
||||
href: url
|
||||
})
|
||||
),
|
||||
[
|
||||
' <script type="text/javascript">',
|
||||
template(' __meteor_runtime_config__ = JSON.parse(decodeURIComponent(<%= conf %>));')({
|
||||
conf: meteorRuntimeConfig
|
||||
}),
|
||||
' if (/Android/i.test(navigator.userAgent)) {',
|
||||
// When Android app is emulated, it cannot connect to localhost,
|
||||
// instead it should connect to 10.0.2.2
|
||||
// (unless we\'re using an http proxy; then it works!)
|
||||
' if (!__meteor_runtime_config__.httpProxyPort) {',
|
||||
' __meteor_runtime_config__.ROOT_URL = (__meteor_runtime_config__.ROOT_URL || \'\').replace(/localhost/i, \'10.0.2.2\');',
|
||||
' __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL = (__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL || \'\').replace(/localhost/i, \'10.0.2.2\');',
|
||||
' }',
|
||||
' }',
|
||||
' </script>',
|
||||
'',
|
||||
' <script type="text/javascript" src="/cordova.js"></script>'
|
||||
],
|
||||
(js || []).map(({ url }) =>
|
||||
template(' <script type="text/javascript" src="<%- src %>"></script>')({
|
||||
src: url
|
||||
href: file.url,
|
||||
})
|
||||
),
|
||||
|
||||
(additionalStaticJs || []).map(({ contents, pathname }) => (
|
||||
(inlineScriptsAllowed
|
||||
' <script type="text/javascript">',
|
||||
template(' __meteor_runtime_config__ = JSON.parse(decodeURIComponent(<%= conf %>));')({
|
||||
conf: meteorRuntimeConfig,
|
||||
}),
|
||||
' if (/Android/i.test(navigator.userAgent)) {',
|
||||
// When Android app is emulated, it cannot connect to localhost,
|
||||
// instead it should connect to 10.0.2.2
|
||||
// (unless we\'re using an http proxy; then it works!)
|
||||
' if (!__meteor_runtime_config__.httpProxyPort) {',
|
||||
' __meteor_runtime_config__.ROOT_URL = (__meteor_runtime_config__.ROOT_URL || \'\').replace(/localhost/i, \'10.0.2.2\');',
|
||||
' __meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL = (__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL || \'\').replace(/localhost/i, \'10.0.2.2\');',
|
||||
' }',
|
||||
' }',
|
||||
' </script>',
|
||||
'',
|
||||
' <script type="text/javascript" src="/cordova.js"></script>',
|
||||
|
||||
...(js || []).map(file =>
|
||||
template(' <script type="text/javascript" src="<%- src %>"></script>')({
|
||||
src: file.url,
|
||||
})
|
||||
),
|
||||
|
||||
...(additionalStaticJs || []).map(({ contents, pathname }) => (
|
||||
inlineScriptsAllowed
|
||||
? template(' <script><%= contents %></script>')({
|
||||
contents: contents
|
||||
contents,
|
||||
})
|
||||
: template(' <script type="text/javascript" src="<%- src %>"></script>')({
|
||||
src: rootUrlPathPrefix + pathname
|
||||
}))
|
||||
})
|
||||
)),
|
||||
'',
|
||||
head,
|
||||
'</head>',
|
||||
'',
|
||||
'<body>',
|
||||
].join('\n');
|
||||
|
||||
[
|
||||
'',
|
||||
head,
|
||||
'</head>',
|
||||
'',
|
||||
'<body>',
|
||||
],
|
||||
).join('\n');
|
||||
|
||||
export const closeTemplate = () =>
|
||||
[].concat([ '</body>','</html>' ]).join('\n');
|
||||
export function closeTemplate() {
|
||||
return "</body>\n</html>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user