Formatted reading

I thought it might be useful if reading could at least sort of mirror writing. For example, if I write some output like:

somefile << "foo: " << foo << ", bar: " << bar; 

…it would be nice if I could read it back in like:

somefile >> "foo: " >> foo >> ", bar: " >> bar; 

So, this code attempts to support that:

#ifndef FMT_READ_H_ #define FMT_READ_H_ #include <cctype> #include <iostream> #include <locale>  template <class charT> std::basic_istream<charT> &operator>>(std::basic_istream<charT> &is, charT const *fmt) {     if (fmt == nullptr)         return is;      if (is.flags() & std::ios_base::skipws) {         std::locale const &loc = is.getloc();         if (std::has_facet<std::ctype<charT>>(loc)) {             auto const &ct = std::use_facet<std::ctype<charT>>(loc);             while (ct.is(std::ctype_base::blank, is.peek()))                 is.ignore(1);         }         else             while (std::isspace(is.peek()))                 is.ignore(1);     }      while (*fmt) {         if (*fmt != is.peek())             is.setstate(std::ios_base::failbit);         ++fmt;         is.ignore(1);     }     return is; }  #endif 

Here’s a little bit of test code:

#include <sstream> #include <iostream> #include "fmt_read.hpp"  int main() {      std::istringstream b("START(0, 0)\nGOAL(1,2)");      int startX, startY;     b >> "START(" >> startX >> "," >> startY >> ")";     std::cout << "start_x: " << startX << ", start_y: " << startY << "\n";      int goalX, goalY;     b >> "GOAL(" >> goalX >> "," >> goalY >> ")";     std::cout << "goal_x: " << goalX << ", goal_y: " << goalY << "\n"; } 

One big question in my mind is about what it does if it finds that the stream has been imbued with locale that doesn’t contain a ctype facet. Right now, in that case it falls back to the global locale–but I’m wondering whether it might be better to treat that as an error instead (but even then, not sure if it should set the failbit, or maybe throw an exception, or…)

How to print text (formatted, long) in twig without raw filter?

We have a text (formatted, long) field that is used to insert embed code such as the Youtube embed code for videos.

When printing the field in twig we are finding that rather than rendering the embed code, it is displaying the embed code as string. To get around this, we currently apply Twig’s Raw filter, but wanted to see if there was a way to not use the raw filter and render the field as is.

Content type (basic page):

  1. body (text, formatted long) field
  2. title

Current results (inserted into Body field using Full HTML text format, displayed as string):

<script type="text/javascript" id="vidyard_embed_code_SkWfXrpFKFpS9JrytJwqMt" src="//play.vidyard.com/SkWfXrpFKFpS9JrytJwqMt.js?v=3.1.1&type=lightbox"></script><div class="outer_vidyard_wrapper"><div class="vidyard_wrapper" onclick="fn_vidyard_SkWfXrpFKFpS9JrytJwqMt();"><img width="360" src="//play.vidyard.com/SkWfXrpFKFpS9JrytJwqMt.jpg?" alt="Generating Leads with Video Content"><div class="vidyard_play_button"><a href="javascript:void(0);"></a></div></div></div> 

Desired results (output of body field shows the video)

Video shown

Firebase – onAuthStateChanged does not return correct formatted object

My app is working correctly until a few minutes ago.

According to documentation, the user object returned will have following properties:

firebase.auth().onAuthStateChanged(function(user) {   if (user) {     var displayName = user.displayName;     var email = user.email;     var emailVerified = user.emailVerified;     var photoURL = user.photoURL;     var isAnonymous = user.isAnonymous;     var uid = user.uid;     var providerData = user.providerData;   } else {     // User is signed out.   } }); 

If I want to access uid, I can just call user.uid.

But the problem is I discovered this behavior is broken while I was developing new features a few minutes ago.

If I want to access properties like uid or email, now I need to access it like this:

user._user.uid or user._user.email

Why does this happened?

Is Firebase doing any update?