How to load jinja template directly from filesystem

Here’s how: use a FileSystemLoader instead of a PackageLoader. I found examples on the web here and here. Let’s say you have a python file in the same dir as your template: ./index.py ./template.html This index.py will find the template and render it: #!/usr/bin/python import jinja2 templateLoader = jinja2.FileSystemLoader(searchpath=”./”) templateEnv = jinja2.Environment(loader=templateLoader) TEMPLATE_FILE = “template.html” … Read more

Check if a class has a member function of a given signature

Here’s a possible implementation relying on C++11 features. It correctly detects the function even if it’s inherited (unlike the solution in the accepted answer, as Mike Kinghan observes in his answer). The function this snippet tests for is called serialize: #include <type_traits> // Primary template with a static assertion // for a meaningful error message … Read more

Officially, what is typename for?

Following is the quote from Josuttis book: The keyword typename was introduced to specify that the identifier that follows is a type. Consider the following example: template <class T> Class MyClass { typename T::SubType * ptr; … }; Here, typename is used to clarify that SubType is a type of class T. Thus, ptr is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)