mirror of
https://github.com/pantor/inja.git
synced 2026-03-15 13:41:25 +00:00
Merge pull request #48 from pantor/include-json-in-inja
This commit is contained in:
@@ -22,11 +22,11 @@ inja::render("Hello {{ name }}!", data); // Returns "Hello world!"
|
||||
|
||||
## Integration
|
||||
|
||||
Inja is a headers only library, which can be downloaded from the [releases](https://github.com/pantor/inja/releases) or directly from the `src/` folder. Inja uses json by nlohmann as its single dependency, so make sure that it is included before inja. json can be found [here](https://github.com/nlohmann/json/releases).
|
||||
Inja is a headers only library, which can be downloaded from the [releases](https://github.com/pantor/inja/releases) or directly from the `src/` folder. Inja uses `nlohmann/json.hpp` as its single dependency, so make sure it can be included from `inja.hpp`. json can be downloaded [here](https://github.com/nlohmann/json/releases). Then integration is as easy as:
|
||||
|
||||
```c++
|
||||
#include "json.hpp"
|
||||
#include "inja.hpp"
|
||||
#include <inja.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
// For convenience
|
||||
using namespace inja;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
project('inja', 'cpp', default_options : ['cpp_std=c++11'])
|
||||
|
||||
inja_inc = include_directories('src')
|
||||
|
||||
inja_dep = declare_dependency(
|
||||
include_directories : inja_inc
|
||||
include_directories : include_directories('src')
|
||||
)
|
||||
|
||||
subdir('test')
|
||||
|
||||
15
src/inja.hpp
15
src/inja.hpp
@@ -33,20 +33,17 @@ SOFTWARE.
|
||||
#define PANTOR_INJA_VERSION_PATCH 1
|
||||
|
||||
|
||||
#ifndef NLOHMANN_JSON_HPP
|
||||
static_assert(false, "nlohmann/json not found.");
|
||||
#endif
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <map>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace inja {
|
||||
|
||||
@@ -4,8 +4,7 @@ unit_test = executable(
|
||||
'src/unit-files.cpp',
|
||||
'src/unit-renderer.cpp',
|
||||
'src/unit-string-helper.cpp',
|
||||
dependencies: inja_dep,
|
||||
include_directories: include_directories('thirdparty')
|
||||
dependencies: inja_dep
|
||||
)
|
||||
|
||||
test('Inja unit test', unit_test)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "catch/catch.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "inja.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "catch/catch.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "inja.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "catch/catch.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "inja.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user