roboshoes / grunt-json-bake

Grunt plugin that lets you merge multiple JSON files into one.
MIT License
7 stars 3 forks source link

Support including HTML files as JSON strings #1

Closed nikolaygit closed 10 years ago

nikolaygit commented 10 years ago

Hi Mathias,

thank you for the great plugin! Would you be open for a pull request to support including HTML files as strings:

source.json:

{
    "contents": "{{contents.html}}"
}

contents.html

You can visit our <a href="http://link.com">website</a>.

dist.json

{
    "contents": "You can visit our <a href=\"http://link.com\">website</a>."
}
roboshoes commented 10 years ago

Yes I would. Also brings up the question. should files that are not JSON always be read as a string, much like you propose with the HTML file.

Thoughts?

nikolaygit commented 10 years ago

I would go for the following options:

Grunt.js

json_bake: {
    your_target: {
        options: {
            // if no includeFiles are defined, automatically *.json is included as json object, all text files are included as string with empty separator.
            // otherwise, the user can overwrite and add new result formats explicitly in the includeFiles option
            includeFiles : {
                // these are default values, the user can change them
                html: { resultType: "string", separator: ""  },
                csv: { resultType: "string", separator: ";"  },
                json: { resultType: "json"}
            }
        },
        files: {
            "dist/final.json": "app/base.json"
        }
    }
}
nikolaygit commented 10 years ago

PR #2 created.