Skip to content

Instantly share code, notes, and snippets.

@benthebear
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benthebear/9d9cc78ce31e25650cd1 to your computer and use it in GitHub Desktop.
Save benthebear/9d9cc78ce31e25650cd1 to your computer and use it in GitHub Desktop.
/*
* Draws a new card in the document <body>.
*/
function renderPainting() {
var postings = [
{
pictureName: 'Starry Night',
artist: 'Vincent van Gogh',
year: 1889,
image: '1.jpg'
},
{
pictureName: 'Gas',
artist: 'Edward Hopper',
year: 1851,
image: '2.jpg'
},
{
pictureName: 'The Wounded Deer',
artist: 'Frida Kahlo',
year: 1947,
image: '3.jpg'
},
{
pictureName: 'A View of Exeter',
artist: 'JMW Turner',
year: 1827,
image: '4.jpg'
},
];
var rawTemplate = $("#render-newCard").html()
for (var i = 0; i < 4 ; i++) {
var currentObject = postings[i];
var filledTemplate = Mustache.render(rawTemplate,currentObject);
$("#wunderbar").append (filledTemplate)
}
}
renderPainting()
function getRandom (gallery)
{
var apiValues = gallery;
var rawTemplate = $("#render-newAPI").html();
for (var i=0; i<4; i++) {
var completeTemplate = Mustache.render(rawTemplate, getRandomElement(apiValues));
$("#randomness").append (completeTemplate);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment