Created
March 14, 2013 04:46
-
-
Save zakdances/5158875 to your computer and use it in GitHub Desktop.
Pass a selector of elements you want to scrub clean of PyJade bugs.
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
fixPyJadeBugs = (sels) -> | |
sels.each () -> | |
element = $(this) | |
fix = (attrib) -> | |
value = attrib.value.replace /_/g, ' ' | |
if value[0] == '"' and ( value[value.length-1] == '"' or ( value[value.length-2] == '"' and value[value.length-1] == '/' ) ) | |
max = if value[value.length-1] == '/' then value.length-2 else value.length-1 | |
element.attr attrib.name, value.substring('1',max) | |
if attrib.name == 'data-class' | |
element.addClass element.data('class') | |
return | |
$.each this.attributes, (i, attrib) -> | |
if attrib.name != 'class' and attrib.name != 'id' | |
fix attrib | |
return | |
return | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment