grunt-bake
Advanced tools
Comparing version 0.3.1 to 0.3.3
@@ -11,3 +11,3 @@ /* | ||
function parseFunction( source ) { | ||
return source.replace( /\{\{([.\-\w]*)\}\}/g, function() { | ||
return source.replace( /\{\{\s?([\.\-\w]*)\s?\}\}/g, function() { | ||
return ""; | ||
@@ -31,2 +31,8 @@ } ); | ||
jsonlint: { | ||
config: { | ||
src: [ "package.json" ] | ||
} | ||
}, | ||
clean: { | ||
@@ -36,2 +42,28 @@ tests: [ "tmp" ], | ||
nodeunit: { | ||
tests: [ "test/*_test.js" ], | ||
}, | ||
watch: { | ||
jshint: { | ||
files: [ | ||
"Gruntfile.js", | ||
"tasks/*.js", | ||
"<%= nodeunit.tests %>", | ||
], | ||
tasks: [ "jshint" ] | ||
}, | ||
jsonlint: { | ||
files: [ "package.json" ], | ||
tasks: [ "jsonlint" ] | ||
}, | ||
test: { | ||
files: [ | ||
"tasks/*.js", | ||
"<%= nodeunit.tests %>", | ||
], | ||
tasks: [ "jshint", "test" ] | ||
} | ||
}, | ||
bake: { | ||
@@ -153,24 +185,2 @@ default_bake: { | ||
} | ||
}, | ||
nodeunit: { | ||
tests: [ "test/*_test.js" ], | ||
}, | ||
watch: { | ||
jshint: { | ||
files: [ | ||
"Gruntfile.js", | ||
"tasks/*.js", | ||
"<%= nodeunit.tests %>", | ||
], | ||
tasks: [ "jshint" ] | ||
}, | ||
test: { | ||
files: [ | ||
"tasks/*.js", | ||
"<%= nodeunit.tests %>", | ||
], | ||
tasks: [ "jshint", "test" ] | ||
} | ||
} | ||
@@ -186,6 +196,7 @@ | ||
grunt.loadNpmTasks( "grunt-contrib-watch" ); | ||
grunt.loadNpmTasks( "grunt-jsonlint" ); | ||
grunt.registerTask( "test", [ "clean", "bake", "nodeunit" ] ); | ||
grunt.registerTask( "default", [ "jshint", "test" ] ); | ||
grunt.registerTask( "default", [ "jsonlint", "jshint", "test" ] ); | ||
}; |
{ | ||
"name": "grunt-bake", | ||
"description": "Bake external includes into files to create static pages with no server-side compilation time", | ||
"version": "0.3.1", | ||
"version": "0.3.3", | ||
"homepage": "https://github.com/MathiasPaumgarten/grunt-bake", | ||
@@ -39,2 +39,3 @@ "author": { | ||
"grunt-contrib-watch": "~0.4.3", | ||
"grunt-jsonlint": "~1.0.1", | ||
"grunt": "~0.4.0" | ||
@@ -41,0 +42,0 @@ }, |
@@ -120,2 +120,8 @@ # grunt-bake [![Build Status](https://travis-ci.org/MathiasPaumgarten/grunt-bake.png?branch=master)](https://travis-ci.org/MathiasPaumgarten/grunt-bake) | ||
#### options.parsePattern | ||
Type: `Regex` | ||
Default value: `/\{\{\s?([\.\-\w]*)\s?\}\}/g` | ||
Determines the regex to parse the files in order to insert the content from the JSON file. The default pattern allows place holders such as: `{{value}}`. | ||
#### options.process | ||
@@ -126,3 +132,3 @@ Type: `Function` | ||
A Function which is used to process the template before putting it into the file. If `process` is defined as `null` or `false` the includes won't be processed at all. | ||
The default process uses two curly braces as marker, such as `{{json.value.name}}`. | ||
The default process uses two curly braces as marker, such as `{{json.value.name}}`. However the the parse regex is costumizable using `options.parsePattern`. | ||
@@ -129,0 +135,0 @@ The function gets passed two arguments: |
@@ -19,16 +19,2 @@ /* | ||
// ======================= | ||
// -- DEFAULT PROCESSOR -- | ||
// ======================= | ||
// This process method is used when no process function is supplied. | ||
function defaultProcess( template, content ) { | ||
return template.replace( /\{\{([.\-\w]*)\}\}/g, function( match, key ) { | ||
return resolveName( key, content ); | ||
} ); | ||
} | ||
// ============= | ||
@@ -38,3 +24,3 @@ // -- OPTIONS -- | ||
// Merging the passed otions with the default settingss | ||
// Merging the passed options with the default settingss | ||
@@ -45,3 +31,3 @@ var options = this.options( { | ||
basePath: "", | ||
process: defaultProcess | ||
parsePattern: /\{\{\s*([\.\-\w]*)\s*\}\}/g | ||
} ); | ||
@@ -53,2 +39,19 @@ | ||
// ======================= | ||
// -- DEFAULT PROCESSOR -- | ||
// ======================= | ||
// This process method is used when no process function is supplied. | ||
function defaultProcess( template, content ) { | ||
return template.replace( options.parsePattern, function( match, key ) { | ||
return resolveName( key, content ); | ||
} ); | ||
} | ||
if ( ! options.hasOwnProperty( "process" ) ) { | ||
options.process = defaultProcess; | ||
} | ||
// =========== | ||
@@ -159,2 +162,5 @@ // -- UTILS -- | ||
// Handle _if attributes in inline arguments | ||
function validateIf( inlineValues, values ) { | ||
@@ -172,2 +178,5 @@ if ( "_if" in inlineValues ) { | ||
// Handle _foreach attributes in inline arguments | ||
function validateForEach( inlineValues, values, array ) { | ||
@@ -174,0 +183,0 @@ |
Sorry, the diff of this file is not supported yet
28019
425
426
6