Some repairs for md_parser and template engine.
This commit is contained in:
parent
8705859115
commit
22157169c0
14 changed files with 180 additions and 159 deletions
|
@ -1,15 +1,29 @@
|
|||
#include "TemplatingEngine.h"
|
||||
#include "TemplateSubstitutionContext.h"
|
||||
|
||||
#include "File.h"
|
||||
|
||||
#include "TestFramework.h"
|
||||
#include "TestUtils.h"
|
||||
|
||||
TEST_CASE(TestTemplatingEngine, "compiler")
|
||||
TEST_CASE(TestTemplatingEngine_BlockInherit, "compiler")
|
||||
{
|
||||
auto engine = TemplatingEngine(TestUtils::getTestDataDir());
|
||||
const auto content = engine.renderTemplate("index", nullptr);
|
||||
|
||||
File outfile(TestUtils::getTestOutputDir() / "index.html");
|
||||
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");
|
||||
outfile.writeText(content);
|
||||
}
|
||||
|
|
|
@ -1,30 +1,7 @@
|
|||
# I'm a level one header
|
||||
I'm some text under level one
|
||||
|
||||
## I'm a level two header
|
||||
I'm some text under level two
|
||||
|
||||
```
|
||||
I'm a code block
|
||||
```
|
||||
|
||||
I'm a line under the code block, with some `inline code`.
|
||||
|
||||
### I'm a level three header
|
||||
I'm a bullet point list:
|
||||
|
||||
* First point
|
||||
* Second point
|
||||
* Third point
|
||||
|
||||
With a [hyperlink](www.imahyperlink.com) embedded.
|
||||
|
||||
# I'm another level one header
|
||||
|
||||
I'm some inline math $a = b + c$ and I'm some standalone math:
|
||||
|
||||
$$
|
||||
d = e + f
|
||||
$$
|
||||
|
||||

|
||||
With some test after.
|
||||
|
|
10
test/data/simple_template.html
Normal file
10
test/data/simple_template.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<title>My title</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">{{ content }}</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue