changeset 823:da4c30a8bcdd templating

plustache
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 May 2014 16:21:48 +0200
parents 7ce875531950
children d8f5de5b9517
files CMakeLists.txt Resources/CMake/PlustacheConfiguration.cmake UnitTestsSources/Plustache.cpp
diffstat 3 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Thu May 08 17:16:10 2014 +0200
+++ b/CMakeLists.txt	Wed May 28 16:21:48 2014 +0200
@@ -76,6 +76,7 @@
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LuaConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
+include(${CMAKE_SOURCE_DIR}/Resources/CMake/PlustacheConfiguration.cmake)
 
 
 if (${ENABLE_SSL})
@@ -281,6 +282,7 @@
   UnitTestsSources/Lua.cpp
   UnitTestsSources/MultiThreading.cpp
   UnitTestsSources/UnitTestsMain.cpp
+  UnitTestsSources/Plustache.cpp
   )
 target_link_libraries(UnitTests ServerLibrary CoreLibrary)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Resources/CMake/PlustacheConfiguration.cmake	Wed May 28 16:21:48 2014 +0200
@@ -0,0 +1,16 @@
+set(PLUSTACHE_SOURCES_DIR ${CMAKE_BINARY_DIR}/plustache-0.3.0)
+DownloadPackage(
+  "6162946bdb3dccf3b2185fcf149671ee"
+  "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/plustache-0.3.0.tar.gz"
+  "${PLUSTACHE_SOURCES_DIR}")
+
+list(APPEND THIRD_PARTY_SOURCES
+  ${PLUSTACHE_SOURCES_DIR}/src/context.cpp
+  ${PLUSTACHE_SOURCES_DIR}/src/template.cpp
+  )
+
+include_directories(
+  ${PLUSTACHE_SOURCES_DIR}
+  )
+
+source_group(ThirdParty\\Plustache REGULAR_EXPRESSION ${PLUSTACHE_SOURCES_DIR}/.*)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UnitTestsSources/Plustache.cpp	Wed May 28 16:21:48 2014 +0200
@@ -0,0 +1,13 @@
+#include "gtest/gtest.h"
+
+#include <include/template.hpp>
+
+TEST(Plustache, Basic)
+{
+  std::map<std::string, std::string> ctx;
+  ctx["title"] = "About";
+
+  Plustache::template_t t;
+  ASSERT_EQ("<h1>About</h1>", t.render("<h1>{{title}}</h1>", ctx));
+}
+