Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Conversation

@jonaslewin
Copy link
Contributor

Hello. I would like to use gulp-file-include to break up our json files which are very large.
It works fine, but I want to be able to support this case:
{key: @@include('a.json')}
But this is not valid json. However this would be valid json:
{key: "@@include('a.json')"}

I have tried the following test case to see that it works.
my settings:

.pipe(fileinclude({
    prefix: '"@@',
    suffix: '@@"',
    basepath: '@file'
}))

index.json:

{
    "start": 1,
    "firstObject": "@@include('./partial1.json')@@",
    "ifTrue": "@@if (1+1 === 2) {"@@include('./partial3.json')@@"}@@",
    "ifFalse": {"@@if (1+1 === 1) {"@@include('./partial3.json')@@"}@@"},
    "someObject": "@@include('./partial1.json')@@",
    "end": 2
}

partial1.json:

{
        "fromPartial": "true",
        "nestedPartial": {
            "someObject": "@@include('./partial2.json')@@"
        },
        "nestedPartial2": {
            "someObject": "@@include('./partial2.json')@@"
        }

partial2.json:

{
                "fromPartial2": "true",
                "itWorked": "hurray"
            }

partial3.json:

"Content of partial 3"

Resulting json:

{
    "start": 1,
    "firstObject": {
        "fromPartial": "true",
        "nestedPartial": {
            "someObject": {
                "fromPartial2": "true",
                "itWorked": "hurray"
            }
        },
        "nestedPartial2": {
            "someObject": {
                "fromPartial2": "true",
                "itWorked": "hurray"
            }
        },
    "ifTrue": "Content of partial 3",
    "ifFalse": {},
    "someObject": {
        "fromPartial": "true",
        "nestedPartial": {
            "someObject": {
                "fromPartial2": "true",
                "itWorked": "hurray"
            }
        },
        "nestedPartial2": {
            "someObject": {
                "fromPartial2": "true",
                "itWorked": "hurray"
            }
        },
    "end": 2
}

If you don't like this solution I would appreciate that you update gulp-file-include to work with json. I'm sure you would do a better job at this than I did.
Thanks in advance.
/Jonas

@jonaslewin jonaslewin changed the title I have added support for json, and it needs a suffix. Support for valid json syntax and gulp-file-include. Apr 13, 2015
@haoxins haoxins self-assigned this Apr 13, 2015
@haoxins
Copy link
Owner

haoxins commented Apr 14, 2015

land 2a67d07

@haoxins haoxins closed this Apr 14, 2015
@haoxins
Copy link
Owner

haoxins commented Apr 14, 2015

thx 😄

@jonaslewin
Copy link
Contributor Author

Thanks for the accept. What's the next step to get this to be updated when I write npm install gulp-file-include? I just started using npm this week, so I'm quite new on this.

@haoxins
Copy link
Owner

haoxins commented Apr 15, 2015

@janpaepke I'll add a test case and some docs.

@haoxins
Copy link
Owner

haoxins commented Apr 15, 2015

publish within 24h 😄

@janpaepke
Copy link
Contributor

Wrong @ ? :)

@haoxins
Copy link
Owner

haoxins commented Apr 16, 2015

v0.9.0

@jonaslewin
Copy link
Contributor Author

Thanks a lot for all your help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants