From the course: Web Servers and APIs using C++

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Adding dynamic data to a page

Adding dynamic data to a page - C++ Tutorial

From the course: Web Servers and APIs using C++

Adding dynamic data to a page

- [Narrator] We've written our first database query, but the output is pretty ugly. Let's change that. Crow supports a logic list template system named mustache. Mustache makes our C++ data available when the HTML page renders. To use mustache, we need to make a few changes to our code. So let's go ahead and return to Atom, and the very first change that we need to make is just below the namespace crow, we're gonna say using namespace crow::mustache. Next we're gonna add a function called getview, and it's gonna return a type of string and getview, and it's gonna take in a const string reference to filename and a context, context, reference called x, open and closed parentheses. This has just one line, that one line is return load, and we're gonna say filename plus .HTML, so we're adding HTML to the end of the line. Gonna do a .render x semicolon, then we need to just make one more small change. We're gonna copy this…

Contents