-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dynamic includes plugin request #2558
Comments
@acidjazz could be: style
each s in styles
include-dyn `../public/css/${s}` Add |
Take a look... |
@lagden have you gotten this working? it looks abandoned w/ a failing build. |
It may need some small updates, but should be approximately working. If you get it set up, you could submit a pull request. |
I did a workaround using Example using Koa.jsThe server side moduleconst {readFileSync} = require('fs')
const {join} = require('path')
const pugEngine = require('pug')
const Pug = require('koa-pug')
function datasource(file, type, data = {}) {
const content = readFileSync(file, 'utf8')
switch (type) {
case 'json':
return JSON.parse(content)
case 'pug':
return pugEngine.renderFile(content, data)
default:
return content
}
}
const isDev = process.env.NODE_ENV === 'development'
const viewPath = join(__dirname, '..', 'views')
const dataPath = join(__dirname, '..', 'data')
const pug = new Pug({
locals: {isDev, datasource, viewPath, dataPath},
pretty: isDev,
viewPath
})
module.exports = pug The templateextends ../../layout/main
block content
.icon
each item in ['hamburguer','user']
- const svg = datasource(`${viewPath}/shared/icons/${item}.svg`)
!= svg |
I don't understand what the resolution was here. Was this merged in or not? |
ex:
more information can be found here
The text was updated successfully, but these errors were encountered: