I'm looking if its possible when using grunt to build a task that would use my folder structure to build data.
I wanted to build a website from folder structure.
For example I have:
- data
-- folder_n
--- options.json
--- webpagetext.txt
--- additional.html
etc.
Then generate my webpage also in folder structure (folder_n/{variable_as_friendly_url}.html
)
Is it possible to do with grunt? I read most of docs, but did not find if that would be possible.
Edit: How would I see it in PHP
<?php
/*
Basic project structure
templates/
- template_1.php
- template_2.php
- template_3.php
datafeed/
- subpage_1/
-- header_image.png
-- webpagetext.txt
-- options.json
- subpage_2/
-- header_image.png
-- webpagetext.txt
-- options.json
- subpage_3/
-- header_image.png
-- webpagetext.txt
-- options.json
- subpage_n/
-- header_image.png
-- webpagetext.txt
-- options.json
*/
// IN PHP it would look like.
foreach (glob('datafeed/*') as $dir){
foreach(glob('templates/*') as $tpl){
constructpage($dir, $tpl);
}
}
function constructpage($dir, $tpl) {
$options = json_decode($dir.'options.json');
$output_html_file_name = 'output/'.basename($dir) . '/' . basename($dir) . '.html';
/*
Logic that would copy, assign vars etc for template in $tpl.
*/
}
But grunt is my choice because of: I want to learn it, it got some pretty cool tools.