patrickkettner / grunt-compile-handlebars

grunt plugin to compile static html from a handlebars plugin
MIT License
115 stars 29 forks source link

[TASK] config #62

Open marocas opened 8 years ago

marocas commented 8 years ago

Hello, im generating my html, but my utilities data.json are not getting passed. I have installed the latest version, gch, but even so, if i have more than one data.json, gch aint getting the info.

here is my config:

"use strict";

module.exports = {
  main: {
        files: [{
            expand:     true,
            cwd:        "<%= cfg.root %><%= cfg.src.html %>templates/",
            src:        "*.hbs",
            dest:       "<%= cfg.root %><%= cfg.dest.html %>",
            ext:        ".html"
        }],

        preHTML:        "<%= cfg.root %><%= cfg.src.utils %>globals/head.html",
        postHTML:       "<%= cfg.root %><%= cfg.src.utils %>globals/foot.html",

        partials:       "<%= cfg.root %><%= cfg.src.html %>**/*.hbs",

        templateData:   ["html/_patterns/utilities/data/*.json"],
        helpers:        "<%= cfg.root %><%= cfg.src.utils %>helpers/**/*.js"
    }
};

Am i missing something here?

BTW, how can i get from a json file, the name of the first node? I want to get the "icon-adv" name?

{
    "icon-adv": {
        "x": 86,
        "y": 82,
        "width": 43,
        "height": 39,
        "source_image": "html/_images/icons/icon-adv.png",
        "image": "../../../images/icons.png",
        "total_width": 224,
        "total_height": 186,
        "escaped_image": "../../../images/icons.png",
        "offset_x": -86,
        "offset_y": -82,
        "px": {
            "x": "86px",
            "y": "82px",
            "offset_x": "-86px",
            "offset_y": "-82px",
            "height": "39px",
            "width": "43px",
            "total_height": "186px",
            "total_width": "224px"
        }
    },
}

Best regards, Mário Silva.

mikemellor11 commented 8 years ago

60 I believe it's related to this problem, at the minute the path your specifying in templateData is being ignored and it's trying to find the json files in your "<%= cfg.root %><%= cfg.src.html %>templates/" handlebars folder.

If you run the task with verbose you'll see it failing to find the json - grunt compile-handlebars --verbose

Also as icon-adv is a key i don't believe you can actually get the value of the key itself, can you add a property to icon-adv like so:

{
    "icon-adv": {
        "name": "icon-adv",
        "x": 86,
        "y": 82,
        "width": 43,
        "height": 39,
        "source_image": "html/_images/icons/icon-adv.png",
        "image": "../../../images/icons.png",
        "total_width": 224,
        "total_height": 186,
        "escaped_image": "../../../images/icons.png",
        "offset_x": -86,
        "offset_y": -82,
        "px": {
            "x": "86px",
            "y": "82px",
            "offset_x": "-86px",
            "offset_y": "-82px",
            "height": "39px",
            "width": "43px",
            "total_height": "186px",
            "total_width": "224px"
        }
    },
}