帕格:从node_modules访问引导
问题描述:
我使用帕格输出HTML,我用于后续PDF生成与HTML-pdf。帕格:从node_modules访问引导
我的控制器:
// read file
var source = fs.readFileSync(path.resolve(__dirname, 'templates/pdf.pug'), 'utf-8');
// compile pug template and output html
var template = pug.compile(source);
var html = template(data)
我的模板
doctype html
html
head
title Merapi Export
link(rel='stylesheet', href='/node_modules/bootstrap/dist/css/bootstrap.min.css')
body
h1 Merapi Export
有没有办法直接从节点模块集成自举?
答
原来你有基本目录设置为HTML,PDF格式的选项(用于生成PDF)的哈巴狗模板:
base: 'file:///'+__dirname+'/templates/'
一旦做到这一点,你可以这样访问自举:
link(rel='stylesheet', href='../../../../../../node_modules/bootstrap/dist/css/bootstrap.min.css')