import template from './template'; export const headTemplate = ({ css, htmlAttributes, bundledJsCssUrlRewriteHook, head, dynamicHead, }) => { var headSections = head.split(/]*>/, 2); var cssBundle = [...(css || []).map(file => template(' ')({ href: bundledJsCssUrlRewriteHook(file.url), }) )].join('\n'); return [ ' template(' <%= attrName %>="<%- attrValue %>"')({ attrName: key, attrValue: htmlAttributes[key], }) ).join('') + '>', '', dynamicHead, (headSections.length === 1) ? [cssBundle, headSections[0]].join('\n') : [headSections[0], cssBundle, headSections[1]].join('\n'), '', '', ].join('\n'); }; // Template function for rendering the boilerplate html for browsers export const closeTemplate = ({ meteorRuntimeConfig, rootUrlPathPrefix, inlineScriptsAllowed, js, additionalStaticJs, bundledJsCssUrlRewriteHook, }) => [ '', inlineScriptsAllowed ? template(' ')({ conf: meteorRuntimeConfig, }) : template(' ')({ src: rootUrlPathPrefix, }), '', ...(js || []).map(file => template(' ')({ src: bundledJsCssUrlRewriteHook(file.url), }) ), ...(additionalStaticJs || []).map(({ contents, pathname }) => ( inlineScriptsAllowed ? template(' ')({ contents, }) : template(' ')({ src: rootUrlPathPrefix + pathname, }) )), '', '', '', '' ].join('\n');