Skip to content

Instantly share code, notes, and snippets.

@saurik
Forked from balupton/README.md
Created May 19, 2011 04:12
Show Gist options
  • Save saurik/980168 to your computer and use it in GitHub Desktop.
Save saurik/980168 to your computer and use it in GitHub Desktop.
JavaScript VS CoffeeScript
# Generate
generate: (next) ->
# Check
if DocPad.genetating then return
else DocPad.generating = true
# Continue
path.exists DocPad.options.srcPath, (exists) ->
# Check
if not exists then throw Error 'Cannot generate website as the src dir was not found'
# Continue
util.rmdir DocPad.options.outPath, ->
DocPad.generateClean -> <<
DocPad.generateParse -> <<
DocPad.generateRelations -> <<
DocPad.generateRender -> <<
DocPad.generateWrite ->
console.log 'Website Generated'
DocPad.generating = false
if next then next()
/**
* Generate the Static Website
* 1. Clean the Database
* 2. Parse the Source files
* 3. Render the Source Files
*/
generate: function(next) {
if (DocPad.generating)
return;
DocPad.generating = true;
path.exists(DocPad.options.srcPath, function(exists) {
if (!exists)
throw new Error('Cannot generate website as the src path does not exist, run: docpad skeleton');
util.rmdir(DocPad.options.outPath,function() {
DocPad.generateClean(function() {
DocPad.generateParse(function() {
DocPad.generateRelations(function() {
DocPad.generateRender(function() {
DocPad.generateWrite(function() {
console.log('Website Generated');
DocPad.generating = false;
if (typeof next != 'undefined')
next();
}) }) }) }) })
});
});
},
# Generate
generate: (next) ->
# Check
if DocPad.genetating then return
else DocPad.generating = true
# Continue
path.exists DocPad.options.srcPath, (exists) ->
# Check
if not exists then throw Error 'Cannot generate website as the src dir was not found'
# Continue
util.rmdir DocPad.options.outPath, ->
DocPad.generateClean ->
DocPad.generateParse ->
DocPad.generateRelations ->
DocPad.generateRender ->
DocPad.generateWrite ->
console.log 'Website Generated'
DocPad.generating = false
if next then next()
/**
* Generate the Static Website
* 1. Clean the Database
* 2. Parse the Source files
* 3. Render the Source Files
*/
generate: function(next){
if ( DocPad.generating ) return;
DocPad.generating = true;
path.exists(DocPad.options.srcPath,function(exists){
if ( !exists ) {
throw new Error('Cannot generate website as the src path does not exist, run: docpad skeleton');
}
else {
util.rmdir(DocPad.options.outPath,function(){
DocPad.generateClean(function(){
DocPad.generateParse(function(){
DocPad.generateRelations(function(){
DocPad.generateRender(function(){
DocPad.generateWrite(function(){
console.log('Website Generated');
DocPad.generating = false;
if ( next ) next();
})
})
})
})
})
});
}
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment