Another funny issue I ran into: apparently jquery can not find elements by ID (#) if the ID string starts with a hashtag (#). In my case, I was using IDs generated from twitter hashtags, and as you know hashtags start with #
So, using $(‘p##myhashtag’).html() did not work. What I could do, is to change the ID of the element and remove the # from the ID. But how do you do it with jade?
That’s when variable support in jade comes in handy! You can manipulate your data right in jade templates using regular javascript. Here’s a snippet that removes hashtag (first character in your string):
- var st = hashtag - var len = st.length - var myst = st.substr(1,len) p(id=myst)
I would recommend combining everything into:
p(id=hashtag.slice(1))