Skip to content

Instantly share code, notes, and snippets.

@davidrhoden
Created October 4, 2012 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davidrhoden/3836780 to your computer and use it in GitHub Desktop.
Save davidrhoden/3836780 to your computer and use it in GitHub Desktop.
// just logging the output from underscore.js .each function, pulling in some json data.
var portfolio = '<% _.each(projects, function(iimage, iproject, ilink_to_more_copy, iimage_name, pproject_name, pproject_subtitle, pproject_desc, iimage_desc){ console.log("iimage:", iimage, "iproject", iproject, "ilink_to_more_copy", ilink_to_more_copy, "iimage_name",iimage_name, pproject_name, "pproject_subtitle:", pproject_subtitle, "pproject_desc", pproject_desc, "iimage_desc", iimage_desc); } ) %>';
var template = _.template(portfolio, {projects : [{"iimage":"GHI_Mothers2.jpg","iproject":"5","ilink_to_more_copy":"","iimage_name":"","iimage_desc":"GHI Physicians are the types of professionals that can do anything and go anywhere they choose in life. The Mothers Campaign captures the emotion during those once-in-a-lifetime events when their children make them prouder than they ever could have ever imagined. In this campaign, those momentous occasions happen to correspond directly with the choice they make to become part of the GHI Health Insurance Network. In 2007, GHI merged with HIP to form EmblemHealth. \r\n","pproject_name":"Mothers Campaign","pproject_subtitle":"","pproject_webname":"ghi","pproject_desc":"GHI Physicians are the types of professionals that can do anything and go anywhere they choose in life. The Mothers Campaign captures the emotion during those once-in-a-lifetime events when their children make them prouder than they ever could have ever imagined. In this campaign, those momentous occasions happen to correspond directly with the choice they make to become part of the GHI Health Insurance Network. In 2007, GHI merged with HIP to form EmblemHealth. "},{"iimage":"Firefighter.jpg","iproject":"1","ilink_to_more_copy":"Read Eugene's story","iimage_name":"Eugene Stolowski","iimage_desc":"It was the infamous Black Sunday fire. Fireman Eugene Stolowski was trapped on the fourth floor with one way out: the window. He jumped. Amazingly, he didn","pproject_name":"Hospital Heroes","pproject_subtitle":"","pproject_webname":"newyorkpresbyterian","pproject_desc":"The Amazing Things Are Happening Here print advertising ran full-spread in global publications such as the Wall Street Journal and Continental Airlines in-flight magazines. The ads that ran in The Wall Street Journal received the highest Starch scores ever for any hospital. The photography was shot by Pulitzer Prize Winner David Hume Kennerly. I am honored to have been a part of the team that brought the Amazing Things concept to realization. \r\n"},{"iimage":"Diversified_2.jpg","iproject":"11","ilink_to_more_copy":"","iimage_name":"","iimage_desc":"Jennifer is a 45 year-old, mid-career college professor who is about to receive tenure due to the retirement of another professor. She","pproject_name":"VARIABLE DATA COMMUNICATIONS","pproject_subtitle":"","pproject_webname":"diversified","pproject_desc":""},{"iimage":"GHI_Mothers.jpg","iproject":"5","ilink_to_more_copy":"","iimage_name":"","iimage_desc":"GHI Physicians are the types of professionals that can do anything and go anywhere they choose in life. The Mothers Campaign captures the emotion during those once-in-a-lifetime events when their children make them prouder than they ever could have ever imagined. In this campaign, those momentous occasions happen to correspond directly with the choice they make to become part of the GHI Health Insurance Network. In 2007, GHI merged with HIP to form EmblemHealth. \r\n","pproject_name":"Mothers Campaign","pproject_subtitle":"","pproject_webname":"ghi","pproject_desc":"GHI Physicians are the types of professionals that can do anything and go anywhere they choose in life. The Mothers Campaign captures the emotion during those once-in-a-lifetime events when their children make them prouder than they ever could have ever imagined. In this campaign, those momentous occasions happen to correspond directly with the choice they make to become part of the GHI Health Insurance Network. In 2007, GHI merged with HIP to form EmblemHealth. "},{"iimage":"CHASE_3.jpg","iproject":"8","ilink_to_more_copy":"","iimage_name":"","iimage_desc":"Direct Marketing developed as one component of the JPMorgan Chase ","pproject_name":"CONTINENTAL ONE PASS REWARDS DIRECT MARKETING","pproject_subtitle":"","pproject_webname":"jpmorganchase","pproject_desc":"Direct Marketing developed as one component of the JPMorgan Chase "}]});
console.log(this);
$('#main_image').html(template);
@aclarke-iseatz
Copy link

_.each(projects, function(iimage, iproject, ilink_to_more_copy, iimage_name, pproject_name, pproject_subtitle, pproject_desc, iimage_desc){

should just be
_.each(projects, function(project){ console.log(project.iimage_name); }

at least I think that's how it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment