How to get a list of current variables from Jinja 2 template?

Technically, because context is not passed as a named dictionary, a little work is required to generate a list of the context variables from inside a template. It is possible though. Define a Jinja context function to return the jinja2.Context object, which is essentially a dictionary of the global variables/functions Make that function available in … Read more

GCC(/Clang): Merging functions with identical instructions (COMDAT folding)

Neither GCC nor Clang is a linker, and ICF needs to be done by the linker, or at least with cooperation with the linker. Edit: They don’t do ICF, so yes, distinct instantiations produce distinct code. The GNU gold linker supports ICF with the –icf option, which needs the GCC option -ffunction-sections to be used. … Read more

match case in scala template doesn’t work, in play2

I was hitting the same problem. Enclosing the right part of the case in curly braces fixed the issue for me. This works for me: @user match { case Some(user) => { Welcome, @user.username! } case None => { <a href=”https://stackoverflow.com/questions/9748258/@routes.Application.login”>Login</a> } } Without the braces, it gave an error with the space after the … Read more

Difference between * and node() in XSLT

<xsl:template match=”node()”> is an abbreviation for: <xsl:template match=”child::node()”> This matches any node type that can be selected via the child:: axis: element text-node processing-instruction (PI) node comment node. On the other side: <xsl:template match=”*”> is an abbreviation for: <xsl:template match=”child::*”> This matches any element. The XPath expression: someAxis::* matches any node of the primary node-type … Read more

Template specialization with empty brackets and struct

There are different levels of template specialization: 1) Template declaration (no specialization) template <class Key, class Value> struct Foo {}; 2) Partial specialization template <class Key> struct Foo<Key, int> {}; 3) Full/explicit specialization template <> struct Foo<std::string, int> {}; Then, when instantiating the templates, the compiler will choose the most specialized definition available: Foo<std::string, std::string> … Read more

tech