Ejs_static: require ('./tasks/ejs_static') (grunt)
Configuration method 1:
Ejs_static.js
module.exports=function(grunt){ var config={ dest: 'app/html', path_to_data: 'data/data.json', path_to_layouts: 'app/assets/html/', index_page: 'index', parent_dirs: false, underscores_to_dashes: true, file_extension: '.html' }return {preview: {options: config}, release:{options: grunt.util._.merge({ }, config, { dest:'<%= yeoman.dist %>/html' }) }}}
Data. json
{ index: { meta: { title: Home, description: Compile static html from ejs templates, keywords: gruntplugin, ejs, static html, static site generator, templates, templating engine, template, embedded js } }, about: { path_to_layout: app/assets/html/about.ejs, meta: { title: About, description: Compile static html from ejs templates, keywords: gruntplugin, ejs, static html, static site generator, templates, templating engine, template, embedded js } }}
Reference Method on the ejs template page (corresponding to the meta of each file name): <% = meta. title %>
Configuration method 2:
Ejs_static.js
module.exports=function(grunt){ var config={ dest: 'app/html', path_to_data: 'data/routes.json', path_to_layouts: 'app/assets/html/', index_page: 'index', parent_dirs: false, underscores_to_dashes: true, file_extension: '.html' }return {preview: {options: config}, release:{options: grunt.util._.merge({ }, config, { dest:'<%= yeoman.dist %>/html' }) }}}
Routes. json
{ home: { path_to_layout: app/assets/html/index.ejs, path_to_data: [ data/global.json, {data/meta.json: home} ] }, a: { path_to_layout: app/assets/html/about.ejs, path_to_data: [ data/global.json, data/a.json ] }, b: { path_to_layout: app/assets/html/about.ejs, path_to_data: data/a.json }}
Meta. json
{ home: { title: Grunt EJS Static | Home, description: The demo page for Grunt EJS Static, keywords: gruntplugin, ejs, static html, static site generator, templates, templating engine, template, embedded js }}
Global. json
{ site_name: Grunt EJS Static, google_analytics: XOXOXO}
A. json
{ title: About, description: Compile static html from ejs templates, keywords: gruntplugin, ejs, static html, static site generator, templates, templating engine, template, embedded js}
Reference in the ejs template page: <% = global. site_name %> <% = meta. title %> <% = a. title %>
Note: global in global. site_name corresponds to the json file name loaded by path_to_data.