0

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" />
Giacomo Paita
  • 1,411
  • 2
  • 12
  • 21
  • 1
    This doesn't seem possible with grunt-html-build , a similar kind of option is present in grunt-bake plugin ( https://github.com/MathiasPaumgarten/grunt-bake#inline-section-statement ) – Prayag Verma Jun 28 '15 at 04:39
  • i've made a quick test with the plugin you suggested to me, and it seems work good for my need. if you make an answer, i will upvote you and make your anwer the one that close the issue. :-) – Giacomo Paita Jul 01 '15 at 10:52

1 Answers1

1

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"
        }
    }
  }
})
Prayag Verma
  • 5,581
  • 3
  • 30
  • 56