Last active
August 29, 2015 14:07
-
-
Save irrationalistic/9473fa8f40f6242d5626 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends layout | |
| block content | |
| h1 Hello Boulder! | |
| script. | |
| var names = !{JSON.stringify(data)}; | |
| script(src="main.js") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var MonsterA = function(name){ | |
| this.name = name; | |
| }; | |
| var MonsterB = function(name){ | |
| this.name = name; | |
| }; | |
| console.log(names); | |
| var monsters = names.map(function(dataObject){ | |
| if(dataObject.class === 'a') | |
| return new MonsterA(dataObject.name); | |
| else | |
| return new MonsterB(dataObject.name); | |
| }); | |
| console.log(monsters); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var indexController = { | |
| index: function(req, res) { | |
| var data = [ | |
| {class: 'a', name: 'I Am A'}, | |
| {class: 'b', name: 'I am B'} | |
| ]; | |
| res.render('index', { | |
| data: data | |
| }); | |
| } | |
| }; | |
| module.exports = indexController; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment