Skip to content
This repository has been 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
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