Answer the question
In order to leave comments, you need to log in
gulp loop only takes last value?
There is this gulp code with a loop
`exports.default = compileSaveTool`
function compileSaveTool (cb) {
...
for (const tool in allCodes) {
for (const code of allCodes[tool]) {
const lang = code.length === 2 ? code : code.slice(0, -3)
compile(allASaveTools, code, lang, allCodes, tool)
}
}
cb()
}
function compile (allASaveTools, code, lang, allCodes, tool) {
/** Сборка HTML на конкретном языке */
const langFile = yaml.safeLoad(
fs.readFileSync(`${srcDir}/lang/landing/${lang}.yaml`, 'utf8')
)
const JsChunks = utils.getAppJsChunks()
const CssChunks = utils.getAppCssChunks()
const langInfo = require(`${srcDir}/lang/langInfo.json`)
const content = fs.readFileSync(
`${srcDir}/lang/save_tools/${lang}/${tool}.md`,
'utf8'
)
// FIXME тут ГЛЮК! почему-то используется послежний язык в списке
const more = {
code, // <=== !!!!!! передаем код в шаблонизатор
langInfo,
content: md.render(content),
filename: tool,
allASaveTools: allASaveTools,
h1: allASaveTools[tool][lang]['title'],
moment,
allCodes,
JsChunks,
CssChunks
}
return src(`${srcDir}/templates/save_tools.html.ejs`)
.pipe(ejs(Object.assign(allASaveTools[tool][lang], more, langFile))) // <=== !!!!!! шаблонизатор
.pipe(replace('<img src', '<img loading="lazy" src'))
.pipe(rename('index.html_' + code)) // <=== !!!!!! добавляем к имени файла
.pipe(dest(`dist/${code}/${tool}/`)) // <=== !!!!!! код также в структуре папок
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question