2017-02-26 37 views
0

我使用帕格輸出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 

有沒有辦法直接從節點模塊集成自舉?

回答

0

原來你有基本目錄設置爲HTML,PDF格式的選項(用於生成PDF)的哈巴狗模板:

base: 'file:///'+__dirname+'/templates/' 

一旦做到這一點,你可以這樣訪問自舉:

link(rel='stylesheet', href='../../../../../../node_modules/bootstrap/dist/css/bootstrap.min.css')