How to use the render function from consolidate

Find comprehensive JavaScript consolidate.render code examples handpicked from public code repositorys.

194
195
196
197
198
199
200
201
202
203
   //  文件是.js或者.json才是模板引擎
    if (file.includes('.js') || file.includes('.json')) {
        let content = files[file].contents.toString(); //文件内容
       //  我们将ejs模板引擎的内容找到 才编译
        if (content.includes('<%')) {
            content = await render(content, res);
            files[file].contents = Buffer.from(content); //渲染
        }
    }
})
fork icon0
star icon0
watch icon0

+ 151 other calls in file

177
178
179
180
181
182
183
184
185
186
const str = files[file].contents.toString();
// do not attempt to render files that do not have mustaches
if (!/{{([^{}]+)}}/g.test(str)) {
  return next();
}
handlebars.render(str, metalsmithMetadata, (err, res) => {
  if (err) {
    err.message = `[${file}] ${err.message}`;
    return next(err);
  }
fork icon0
star icon0
watch icon725

+ 11 other calls in file