GrapesJS / export

Export GrapesJS templates in a zip archive
BSD 3-Clause "New" or "Revised" License
76 stars 68 forks source link

[Question]: Export files using array #11

Closed RJCAM closed 4 years ago

RJCAM commented 4 years ago

Hi @artf , sorry to bother but I would like to know if there is any way that we can export files where the file name and its content are inside an array? Example, I know I can do this:

...
'grapesjs-plugin-export': {
    addExportBtn: false,
    btnLabel: "Export ZIP",
    filenamePfx: "GrapeJS-Project",
    filename: null,
    root: {
        some_folder: { // This creates a folder named some_folder
            'some_file.text': 'This is the content of the file'
        }
    }
}
...

But is there a way to make something similar (below) or any logic that I can add files inside array? Like this example:

'grapesjs-plugin-export': {
    addExportBtn: false,
    btnLabel: "Export ZIP",
    filenamePfx: "GrapeJS-Project",
    filename: null,
    root: {
        some_folder: {
            for(let i=0; i < array.length ; i++) // THIS IS AN EXAMPLE OF WHAT I WANT
                array[i].filename: array[i].filecontent // THIS IS AN EXAMPLE OF WHAT I WANT
        }
    }
}
RJCAM commented 4 years ago

I just did it using async function

...
folder_name: async ed => {
    const files = get_file_names();
    return files
},
...