Skip to content

Instantly share code, notes, and snippets.

@oliverbenns
Created February 24, 2015 03:56
Show Gist options
  • Select an option

  • Save oliverbenns/0a3da1e5218c8bf11cc9 to your computer and use it in GitHub Desktop.

Select an option

Save oliverbenns/0a3da1e5218c8bf11cc9 to your computer and use it in GitHub Desktop.
Communities to jade
function createViews(communities) {
communities.forEach(function(community) {
if (community.college !== '') {
var communityView = '';
communityView += 'h1 ' + community.college + '\n' ;
communityView += 'ul\n';
_.forEach(community, function(value, key) {
if (value !== '' && key !== 'college') {
communityView += '\tli \n\t\ta(href="' + value + '", target="_blank") ' + key + '\n';
}
});
var communitySlug = slug(community.college).toLowerCase();
fs.writeFile('./views/' + communitySlug + '.jade', communityView, function(err) {
if (err) {
console.log(err + 'saving ' + communitySlug);
} else {
console.log(communitySlug + ' was saved!');
}
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment