stuff-from-scratch/test/compiler/TestTemplatingEngine.cpp

30 lines
871 B
C++
Raw Normal View History

2022-10-12 08:01:19 +00:00
#include "TemplatingEngine.h"
#include "TemplateSubstitutionContext.h"
2022-10-12 08:01:19 +00:00
2022-11-30 18:28:50 +00:00
#include "File.h"
2022-10-20 08:00:39 +00:00
2022-12-01 10:52:48 +00:00
#include "TestFramework.h"
#include "TestUtils.h"
2022-10-12 08:01:19 +00:00
TEST_CASE(TestTemplatingEngine_BlockInherit, "compiler")
2022-10-12 08:01:19 +00:00
{
2022-12-01 10:52:48 +00:00
auto engine = TemplatingEngine(TestUtils::getTestDataDir());
2022-12-05 17:50:49 +00:00
const auto content = engine.renderTemplate("index", nullptr);
2022-10-12 08:01:19 +00:00
File outfile(TestUtils::getTestOutputDir(__FILE__) / "BlockInherit.html");
outfile.writeText(content);
}
TEST_CASE(TestTemplatingEngine_Simple, "compiler")
{
auto engine = TemplatingEngine(TestUtils::getTestDataDir());
TemplateSubstitutionContext sub_context;
sub_context.addSubstitution("content", "<div><p>test</p></div>");
const auto content = engine.renderTemplate("simple_template", &sub_context);
File outfile(TestUtils::getTestOutputDir(__FILE__) / "Simple.html");
2022-12-01 10:52:48 +00:00
outfile.writeText(content);
2022-11-29 18:00:19 +00:00
}