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

ejs include example: just add a small function  #20

@ghost

Description

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions