I'm using the grunt-html-build plugin to make static site with templates.
I would like to know if it is possible to pass a custom parameter object to the build function of grunt-html-build
, like this:
<!-- build:section layout.head(customSettings) -->
<!-- /build -->
to have in template file, like this:
<title>customSettings.title</title>
<meta property="og:title" content="customSettings.fbTitle" />
Use grunt-bake plugin instead , it has a Inline Section statement which allows for passing custom parameter object , a sample configuration would be
The HTML file where you want to include other content via grunt-bake
<html>
<body>
<!--(bake includes/file.html _section="home")-->
</body>
</html>
The file.html
file
<h1>{{title}}</h1>
<p>{{content}}</p>
The JSON file which contains information about home
object mentioned in _section
attribute
{
"home": {
"title": "Home",
"content": "This is home"
}
}
Lastly the configuration of the grunt-bake
task
grunt.initConfig({
bake: {
build: {
options: {
content: "content.json"
},
files: {
"baked.html": "filetobake.html"
}
}
}
})