Попробуйте это:
const pug = require('pug');
const pbem = require('pbem');
const scope = pbem({
blocksDir: __dirname + 'views/blocks'
}).precompile();
const separateTemplate = pug.compileFile(__dirname + 'views/page.pug');
let renderedSeparateTemplate = separateTemplate({
block: scope.createBlock
});
В шаблонах:
index.pug:
!= block('block-name').local('varName', 'varValue')
blocks/block-name/block-name.pug:
div&attributes( attributes() )
!= element('element-name').local('varName', varName)
https://github.com/bigslycat/pbem