evernote-email
Advanced tools
Comparing version 0.1.0 to 0.1.2
module.exports = function(grunt) { | ||
var fs = require('fs'); | ||
// to change the template you want to compile into HTML update the global config variables | ||
var globalConfig = { | ||
language: 'en', | ||
data: 'welcome', | ||
template: 'welcome', | ||
directory: 'messages' | ||
content: 'welcome-content', // JSON file name without -lang | ||
template: 'welcome-template', // template file name | ||
contentDirectory: 'welcome', // content directory for JSON file | ||
templateDirectory: 'messages', // template directory | ||
buildDirectory: 'welcome-email' // final build directory name | ||
}; | ||
@@ -15,4 +18,4 @@ | ||
if(grunt.option('data') != undefined){ | ||
globalConfig.data = grunt.option('data'); | ||
if(grunt.option('content') != undefined){ | ||
globalConfig.content = grunt.option('content'); | ||
} | ||
@@ -24,6 +27,30 @@ | ||
if(grunt.option('directory') != undefined){ | ||
globalConfig.directory = grunt.option('directory'); | ||
if(grunt.option('contentDirectory') != undefined){ | ||
globalConfig.contentDirectory = grunt.option('contentDirectory'); | ||
} | ||
if(grunt.option('templateDirectory') != undefined){ | ||
globalConfig.templateDirectory = grunt.option('templateDirectory'); | ||
} | ||
if(grunt.option('buildDirectory') != undefined){ | ||
globalConfig.buildDirectory = grunt.option('buildDirectory'); | ||
} | ||
grunt.registerTask('email-builder', function(){ | ||
var filename = 'emails/content/'+ globalConfig.directory + '/'+ globalConfig.data +'-'+ globalConfig.language +'.json', | ||
fileContent = fs.readFileSync(filename), | ||
content = JSON.parse(fileContent); | ||
if(globalConfig.language !== 'en'){ | ||
content.email[0].intl = 'yes'; | ||
} | ||
//Serialize as JSON and Write it to a file | ||
fs.writeFileSync(filename, JSON.stringify(content, null, 4)); | ||
//call compile handlebars | ||
grunt.task.run('compile-handlebars'); | ||
}); | ||
grunt.initConfig({ | ||
@@ -64,14 +91,14 @@ globalConfig: globalConfig, | ||
'compile-handlebars': { | ||
allStatic: { | ||
templateData: 'content/<%= globalConfig.directory %>/<%= globalConfig.data %>-<%= globalConfig.language %>.json', | ||
template: 'templates/<%= globalConfig.directory %>/<%= globalConfig.template %>.handlebars', | ||
output: 'build/<%= globalConfig.directory %>/<%= globalConfig.data %>-<%= globalConfig.language %>.html', | ||
partials: [ | ||
'partials/*.handlebars', | ||
'partials/language/<%= globalConfig.language %>/language.handlebars' | ||
], | ||
globals: [ | ||
], | ||
}, | ||
allStatic: { | ||
templateData: 'emails/content/<%= globalConfig.contentDirectory %>/<%= globalConfig.content %>-<%= globalConfig.language %>.json', | ||
template: 'emails/templates/<%= globalConfig.templateDirectory %>/<%= globalConfig.template %>.handlebars', | ||
output: 'build/<%= globalConfig.buildDirectory %>/<%= globalConfig.content %>-<%= globalConfig.language %>.html', | ||
partials: [ | ||
'emails/partials/*.handlebars', | ||
'emails/partials/language/<%= globalConfig.language %>/language.handlebars' | ||
], | ||
globals: [ | ||
], | ||
}, | ||
}, | ||
jsonlint: { | ||
@@ -78,0 +105,0 @@ sample: { |
{ | ||
"name": "evernote-email", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"description": "Grunt for Evernote Email", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/evernote/email-builder", |
@@ -8,2 +8,8 @@ # Evernote Email Builder | ||
## Getting Started | ||
### Install | ||
```bash | ||
npm install evernote-email | ||
``` | ||
_If you haven't used [grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide._ | ||
@@ -28,8 +34,10 @@ | ||
```bash | ||
```js | ||
var globalConfig = { | ||
language: 'en', | ||
data: 'welcome', | ||
template: 'welcome', | ||
directory: 'messages' | ||
content: 'welcome-content', // JSON file name without -lang | ||
template: 'welcome-template', // template file name | ||
contentDirectory: 'welcome', // content directory for JSON file | ||
templateDirectory: 'messages', // template directory | ||
buildDirectory: 'welcome-email' // final build directory name | ||
}; | ||
@@ -41,3 +49,3 @@ ``` | ||
```bash | ||
grunt compile-handlebars --directory=messages --data=welcome --template=welcome --lang=en | ||
grunt email-builder --content=welcome-content --template=welcome-template --contentDirectory=welcome --templateDirectory=messages --buildDirectory=welcome-email --lang=en | ||
``` | ||
@@ -44,0 +52,0 @@ |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
24322
154
81
2