Skip to content

Instantly share code, notes, and snippets.

@IOZ
Last active August 29, 2015 14:23
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 IOZ/6c72738dc53333cf88e2 to your computer and use it in GitHub Desktop.
Save IOZ/6c72738dc53333cf88e2 to your computer and use it in GitHub Desktop.
Content Parse for Landing Pages
/**
* Content Parser
*/
function parseContent2() {
var imgPath = 'http://images.menswearhouse.com/is/image/JosBank/';
var $content = $('.additionalInfos').clone();
var output = '<div class="contentSectionArea" dir="ltr" id="main"><div><div class="landingPageContent">{{content}}</div></div></div>';
var rePath1 = /\/wps\/wcm\/[a-z]*\/[a-z0-9]*\//g;
var rePath2 = /\.(gif|jpg)\?[A-Z]*\=[A-Z]*/g;
/* remove styles */
$content.find('style').remove();
$content.find('.addLineItem').removeClass('addLineItem').addClass('addlineitm');
/*
Remove extra spaces and display content.
After that copy text from console and put them into http://jsbeautifier.org/
*/
output = output.replace('{{content}}', $content.html())
.replace(/<!--[\s\S]*?-->/g, '')
.replace(/(\r\n|\n|\r)/gm, '').replace(/\s+/g," ")
.replace(rePath1, imgPath)
.replace(rePath2, "");
console.log(output);
}
parseContent2();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment