How do you teach something when you don't know it yourself?
This is a vital question, perhaps the vital question, for a CS educator to deal with, because technologies will keep pushing us.  There is no end to this particular merry-go-round.

I have been stuck, non-stop, in exactly this situation, for the last four years in a high school for gifted students, and I can attest that it is physically, mentally, and emotionally exhausting. It can push you to the edge of a nervous breakdown. It can also be incredibly rewarding, both for you and for the students.  

I claim no special wisdom, but here are some of the techniques I've been using.   I hope will be of help to other teachers gazing down the barrel of a similar gun at some point in their career:


Don't be dishonest with your students or try to hide your lack of background.  There will be moments that you come up short, and your honesty and forthrightness from the start will help to mitigate any loss of trust that students might feel when this happens.
Find several great resources.  Do not depend on one resource to give you the sort of thorough understanding you need to do this well.  A strong textbook is great, if there is one to be found, and can help you both understand the material and sequence your lessons.  However, single-source preparation leads to two problems: (a) your understanding will be brittle, and you will be left with only one way to explain a concept when students are lost, and (b) it will be very difficult to deal with questions, particularly from your brighter students, that go off-script and try to connect with outside ideas.

In my best situations, I will have a textbook, a tutorial series (such as might be found on YouTube or a website somewhere), some exercises to work though, and a tutor to help me when I get stuck.  SE can, itself, act as the last two of these for CS topics in a pinch, though it is not as good of a tutor as an actual tutor, who will build a dialogue and set of understandings with you over time.
Use the lesson planning itself as your final preparation, in which you summarize the key understandings and design exercises to help your students fill in the dots.  Over-prepare your lessons, because your instincts for how long the material will actually take to cover are not yet honed. 

(I once prepared what I thought would be 3 lectures, and ended up delivering it as 1 lecture because things went extremely smoothly.  At the end of the hour, ,I arrived at the end of literally all of the material I had prepared.  The students enthusiastically told me that the lesson had made a lot of sense.  "Great," I thought, "I'm glad that made sense to the students, but what in the world am I going to do tomorrow??")
When students ask interesting, tangential questions, don't be afraid to reply by asking if they would be willing to research it a little and report back to the class next time.  It is important that not every student question become a major research assignment for you.  Instead, choose your battles carefully. Burnout is a real danger, and your time is valuable.  You have made a pact to help guide students through the main topic; don't get caught up in too many tangents on your first pass.
If you're really caught for time, you can simply present learning materials and ask students to work together to try to make sense of it.  Be careful not to do this too often, because while this technique can work reasonably well for your high-fliers, it does not leave you in a position to guide and help the students who really struggle.
Accept that this is an imperfect business.  You will mess up from time to time.  You will make mistakes.  You will arrive at a lecture feeling prepared, receive a student question, and suddenly realize that you don't understand something that you thought you did.  You may even discover that something you taught was outright wrong.  Be prepared to go back to the class and revisit an idea if you screw up.  But also, be prepared to forgive yourself for some amount of weakness.  You are an imperfect being trying to build a learning opportunity for your students, and all you can do is try your best.