Globalize HTML files.
Globalize html files using hadlebars templates and resources, stored in .json files
Installation
- install Grunt
- inspall pluginnpm install grunt-baio-globalize-html --save-dev
- configure (see example bellow)
Grunt Options
'globalize-html' : build : srcDir : 'source directory' resDir : 'resources directory' destDir : 'destination directory'
- source directory - directory with template html files
- resource directory - directory with resource files (in json format)
- dest directory - directory where globalized files placed
Example
Project Structure
+
|
+---+views
|
+---+src
| |
| +---index.html
|
+---+res
|
+---en-EN.json
index.html (handlebars template)
{{MAIN_TITLE}}
en-EN.json (string resources)
"MAIN_TITLE" : "Hello world"
Grunt config
grunt; grunt; grunt;
Run
grunt
Output
Globalized files will be placed in directory views/en-EN
Full path to the output directory composed from destDir
path and name of the resource file (in case of the example en-EN
)
Globalized file
Hello world