Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Pug: relative include/extends in templates #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add filename option to pug compiler
  • Loading branch information
rsify committed Oct 3, 2018
commit ea37a2b67c6391822bc31747e5cd702887b3895f
10 changes: 8 additions & 2 deletions lib/compilers/pug.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
var ensureRequire = require('../ensure-require.js')

module.exports = function (raw, cb, compiler) {
module.exports = function (raw, cb, compiler, filePath) {
ensureRequire('pug', 'pug')
var pug = require('pug')
try {
var html = pug.compile(raw, compiler.options.pug || {})()
var defaultOptions = {
filename: filePath
}
var html = pug.compile(
raw,
Object.assign({}, compiler.options.pug || {}, defaultOptions)
)()
} catch (err) {
return cb(err)
}
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/pug-included.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
div Included content
1 change: 1 addition & 0 deletions test/fixtures/pug.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template lang="pug">
div
h1 This is the app
include ./pug-included
comp-a
comp-b
</template>
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe('vueify', () => {
assertRenderFn(module,
'<div>' +
'<h1>This is the app</h1>' +
'<div>Included content</div>' +
'<comp-a></comp-a>' +
'<comp-b></comp-b>' +
'</div>'
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy