Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

ejs include example: just add a small function #20

Open
ghost opened this issue Aug 2, 2017 · 0 comments
Open

ejs include example: just add a small function #20

ghost opened this issue Aug 2, 2017 · 0 comments

Comments

@ghost
Copy link

ghost commented Aug 2, 2017

webpack.config.js: (module.exports.plugins[])
new HtmlWebpackPlugin({
template: 'src/templates/a.ejs',
filename: 'build/a.html'
})

a.ejs:

<% var inc = function(name, sendData){
return require('./' + name + '.ejs')(sendData ? {data: data} : null);
}; %>

<% var data = require('path/to/data.js'); %>

<!doctype html>
<html><body>
...
<%=inc('b', true) %>
...
</body></html>

b.ejs:

<h1><%=data.title %><h1>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants