我将哈巴狗用作模板引擎。
我可以在页面上加载内容。遵循我的代码片段:
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
第一段的第三个字应为粗体。
第2款中的一词和一词应为粗体。
第3款中最多1个四个词应为粗体。
以此类推
哈巴狗和我的方法是否可以将任意选择的单词设置为粗体?我的在线搜索仍然没有结果。我该怎么办?
答案 0 :(得分:0)
我找到了可行的解决方案。我关心谁:
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);
}
重要的是`。不要与'混淆。模板文字仅适用于back ticks。
div
div= !{explanation}