jweinst1
7/5/2016 - 4:18 PM

wrapping xml closure js

wrapping xml closure js

//closure capture that wraps in XML brackets
function wrap(core){
	return function(wrapper){
		core = "<" + wrapper + ">" + core + "</" + wrapper + ">";
		return core;
	};
}
/*   var a = wrap("foo")
   a
=> [Function]
   a("h1")
=> '<h1>foo</h1>'
   a("h2")
=> '<h2><h1>foo</h1></h2>'
   a("p")
=> '<p><h2><h1>foo</h1></h2></p>'
   */