Browse Source

inja removed

pull/2/head
Ivan Polyakov 2 years ago
parent
commit
e0211053c6
  1. 5
      README.md
  2. 10
      config.mk
  3. 30
      cxx/Response.cxx
  4. 13
      include/Response.hxx

5
README.md

@ -25,11 +25,6 @@ make install clean @@ -25,11 +25,6 @@ make install clean
```
Run `make help` to see targets, flags and arguments.
Extensions
----------
* [inja](https://github.com/pantor/inja) (template rendering,
requires [nlohmann/json](https://github.com/nlohmann/json))
Examples
--------
See [examples](examples).

10
config.mk

@ -31,16 +31,6 @@ ifeq ($(FCGI_SERVER), 1) @@ -31,16 +31,6 @@ ifeq ($(FCGI_SERVER), 1)
LDFLAGS += -lfcgi
endif
#flag Enable inja extension
EXTENSIONS_INJA ?= 0
#arg Dist path. Needed only if inja is enabled.
DIST_PATH = /var/www/html
ifneq ($(EXTENSIONS_INJA), 0)
CXXFLAGS+=-DEXTENSIONS_INJA -DDIST_PATH=\"$(DIST_PATH)\"
CXXSTD=-std=c++17
endif
#flag Multithread support
MT_ENABLED ?= 0
#arg Number of threads. 8 by default.

30
cxx/Response.cxx

@ -3,10 +3,6 @@ @@ -3,10 +3,6 @@
#include "Response.hxx"
#ifdef EXTENSIONS_INJA
#include <inja/inja.hpp>
#endif
using namespace rpd;
int Response::header(const char *key, const char *value)
@ -16,29 +12,3 @@ int Response::header(const char *key, const char *value) @@ -16,29 +12,3 @@ int Response::header(const char *key, const char *value)
key,
value);
}
#ifdef EXTENSIONS_INJA
void Response::render(const char *path, nlohmann::json data)
{
inja::Environment env;
inja::Template tpl;
try {
std::string tplpath = DIST_PATH;
tplpath += path;
tpl = env.parse_template(tplpath);
} catch (inja::FileError &e) {
std::cerr << e.what() << std::endl;
return;
}
try {
std::string result = env.render(tpl, data);
body(result.c_str());
} catch (inja::RenderError &e) {
std::cerr << e.what() << std::endl;
status(rpd_res_st_internal_server_error);
return;
}
}
#endif

13
include/Response.hxx

@ -8,10 +8,6 @@ @@ -8,10 +8,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef EXTENSIONS_INJA
#include <nlohmann/json.hpp>
#endif
namespace rpd {
/*!
* \brief C++ response wrapper.
@ -80,15 +76,6 @@ public: @@ -80,15 +76,6 @@ public:
res->body = strdup(body);
}
#ifdef EXTENSIONS_INJA
/*!
* \brief Render data to HTML template.
* \param path Path to HTML template relative to dist location.
* \param data Template data to interpolate.
*/
void render(const char *path, nlohmann::json data);
#endif
/*!
* \brief Destructor.
*/

Loading…
Cancel
Save