【问题标题】:Pug: accessing bootstrap from node_modulesPug:从 node_modules 访问引导程序
【发布时间】:2017-02-26 11:42:09
【问题描述】:

我正在使用 pug 输出 html,我将其用于以后使用 html-pdf 生成 pdf。

我的控制器:

// 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

有没有办法直接从节点模块集成引导程序?

【问题讨论】:

    标签: node.js twitter-bootstrap pug


    【解决方案1】:

    原来你必须在 html-pdf 的选项中为你的 pug 模板设置一个基本目录(用于生成 pdf):

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

    完成后,您可以像这样访问引导程序:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-22
      • 2016-06-28
      相关资源
      最近更新 更多