Javascript 如何用帕格将句子中的一些词加粗/加粗?
我使用帕格作为模板引擎 我可以在我的页面上加载内容。下面是我的一些代码片段: server.js 帕格介绍 希望的结果 第一段的第三个字应为粗体 第2段的一字和五字应为粗体 第3段中的一至四个字应为粗体 等等Javascript 如何用帕格将句子中的一些词加粗/加粗?,javascript,node.js,pug,jade4j,Javascript,Node.js,Pug,Jade4j,我使用帕格作为模板引擎 我可以在我的页面上加载内容。下面是我的一些代码片段: server.js 帕格介绍 希望的结果 第一段的第三个字应为粗体 第2段的一字和五字应为粗体 第3段中的一至四个字应为粗体 等等 帕格和我的方法有没有办法将任意选择的单词设置为粗体?我的在线搜索仍然没有结果。我怎样才能做到这一点?我已经找到了我的工作解决方案。我关心的是: server.js routing.get('/introduction', (req, resp) => { loadConte
帕格和我的方法有没有办法将任意选择的单词设置为粗体?我的在线搜索仍然没有结果。我怎样才能做到这一点?我已经找到了我的工作解决方案。我关心的是: server.js
routing.get('/introduction', (req, resp) => {
loadContent( function(err, content){
if(content){
resp.render('intro_page', content);
}
});
});
function loadContent( cb ){
const cont = {
explanation: ['Word three of paragraph one shall be bold. ', 'Words one and five of paragraph 2 shall be bold.', 'Words one up to four of paragraph 3 shall be bold.', 'and so on'],
};
return cb(null, cont);
}
div
each paragraph in explanation
div= paragraph
routing.get('/introduction', (req, resp) => {
loadContent( function(err, content){
if(content){
resp.render('intro_page', content);
}
});
});
function loadContent( cb ){
const bo = '<span style="font-weight: bold">';
const bc = '</span>';
const bk = '<br/><br/>';
const cont = {
explanation: [`Word three ${bo} of ${bc} paragraph one shall be bold. ${bo} Words ${bc} one and five ${bo} of ${bc} paragraph 2 shall be bold. ${bo} Words one up to ${bc} four of paragraph 3 shall be bold. ${bk} and so on`],
};
return cb(null, cont);
}
div
div= !{explanation}