Last active
August 2, 2016 13:31
-
-
Save floehopper/69142251354f7563d0567c67f61c45a6 to your computer and use it in GitHub Desktop.
Smart Answers: Link to partial templates on GitHub
This file contains 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
Drag the following link to your browser bookmark toolbar: | |
<a href="javascript:(function()%7BArray.from(document.querySelector('body').querySelectorAll('.blob-code')).forEach(function(el)%20%7Bvar%20matches%20%3D%20el.textContent.match(%2Frender%20partial%5C%3A%20%5B'%22%5D(%5B%5E'%5D%2B)%5B'%22%5D%2F)%3Bif%20(matches)%20%7Bvar%20originalPath%20%3D%20matches%5B1%5D%3Bvar%20pathElements%20%3D%20originalPath.split('%2F')%3Bvar%20lastElement%20%3D%20'_'%20%2B%20pathElements.pop()%3Bif%20(pathElements%5B0%5D%20%3D%3D%20'shared')%20%7BpathElements%5B0%5D%20%3D%20'..%2F..%2Fshared'%3B%7D%3BpathElements.push(lastElement)%3Bvar%20path%20%3D%20pathElements.join('%2F')%3Bconsole.log(path)%3Bvar%20url%20%3D%20new%20URL(path%2C%20document.location).toString()%3Bvar%20anchor%20%3D%20document.createElement('a')%3Banchor.setAttribute('href'%2C%20url)%3Banchor.setAttribute('title'%2C%20lastElement)%3Banchor.setAttribute('style'%2C%20'color%3A%20hotpink')%3Banchor.textContent%20%3D%20originalPath%3Bel.querySelectorAll('*').forEach(function(e)%20%7Be.childNodes.forEach(function(cn%2C%20index)%20%7Bif%20(cn.textContent%20%3D%3D%20originalPath)%20%7Be.insertBefore(anchor%2C%20cn)%3Be.removeChild(cn)%3B%7D%7D)%3B%7D)%3B%7D%7D)%7D)();">Link to partial templates</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment