Skip to content

Instantly share code, notes, and snippets.

@zakdances
Created March 14, 2013 04:46
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 zakdances/5158875 to your computer and use it in GitHub Desktop.
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.
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