@podium/utils
Advanced tools
Comparing version 4.0.0-next.3 to 4.0.0-next.4
@@ -6,2 +6,3 @@ 'use strict'; | ||
const HttpIncoming = require('./http-incoming'); | ||
const document = require('./html-document'); | ||
@@ -241,47 +242,2 @@ /** | ||
/** | ||
* Shared template function for use in layout and podlet | ||
* | ||
* @param {Object} data template argument object | ||
* | ||
* @returns {String} A merged template string | ||
*/ | ||
const template = ({ | ||
head = '', | ||
body = '', | ||
encoding = 'utf-8', | ||
locale = 'en-US', | ||
title = '', | ||
js = [], | ||
css = [], | ||
} = {}) => { | ||
let scripts = js; | ||
let styles = css; | ||
const buildScriptTag = ({ value = '' }) => | ||
`<script src="${value}" defer></script>`; | ||
const buildCSSLinkTag = ({ value = '' }) => | ||
`<link rel="stylesheet" type="text/css" href="${value}">`; | ||
// backwards compatibility for scripts and styles | ||
if (typeof js === 'string') scripts = [{ type: 'default', value: js }]; | ||
if (typeof css === 'string') styles = [{ type: 'default', value: css }]; | ||
return `<!doctype html> | ||
<html lang="${locale}"> | ||
<head> | ||
<meta charset="${encoding}"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> | ||
${styles.map(buildCSSLinkTag).join('\n ')} | ||
${scripts.map(buildScriptTag).join('\n ')} | ||
<title>${title}</title> | ||
${head} | ||
</head> | ||
<body> | ||
${body} | ||
</body> | ||
</html>`; | ||
}; | ||
module.exports.isString = isString; | ||
@@ -299,2 +255,2 @@ module.exports.isFunction = isFunction; | ||
module.exports.HttpIncoming = HttpIncoming; | ||
module.exports.template = template; | ||
module.exports.template = document; |
{ | ||
"name": "@podium/utils", | ||
"version": "4.0.0-next.3", | ||
"version": "4.0.0-next.4", | ||
"description": "Common generic utility methods shared by @podium modules.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22354
7
405