-
Notifications
You must be signed in to change notification settings - Fork 2
Home
C++ XHTML "code-beside" Rendering framework with custom control classes similar to ASP.Net.
- GridIron itself is a self-contained rendering library with self-registering custom controls similar to ASP.NET.
- GridIron was created by Jessica Mulein in 2009 on SourceForge and was developed minimally through 2013. It was revived and retooled in May of 2020, during the COVID-19 Pandemic.
- GridIron, atop Oat++, is a powerful content generation engine
- GridIron is an entirely separate project from Oat++, though the maintainer of Oat++ has been kind enough to offer development support
- An Oat++ integration layer/wrapper library is in https://github.com/ProjectGridIron/gridiron-oatpp
- A full GridIron+=(Oat++) stack example is in https://github.com/ProjectGridIron/gridiron-oatpp-example
Oat++ is a C++ webserver/lightweight framework with a great many useful features like routing and authentication. Project GridIron is a dynamic custom UI/tag control system a bit like the ASP.Net codebehind style and with a structure to create custom controls.
Grid(Network/The Internet) Iron("Big Iron"/Server/Mainframe)
I made it up. ASP.Net (C#.Net/VB.Net/ASP Classic) is essentially XHTML frontends with functional programming backends. In this sense, Project GridIron is much the same, but based on C++ and the Oat++ Framework. Project GridIron does require some minimal boilerplate code, though the pattern will hopefully get "DRY'd up" a little more soon. Interestingly though, Project GridIron brings something I call "autonomous controls" which are <gi:Label auto="true" id="lblTest">Value</gi:Label> instances that automatically create instances that self-register with the Page and instantly allow another place in the XHTML to reference it by its ID, all without writing any backend code at all. <%=lblTest.Text%> would be automatically replaced with "Value". In summation, although some minimal boiler code is required to associate a page's C++ and XHTML files, the XHTML and C++ are essentially equal partners, hence "code-beside".
Example endpoint boilerplate (*the render mechanism is about to change)
ENDPOINT("GET", "/", root) {
GridIron::Page page("crud-exe/testapp.html");
GridIron::controls::Label lblTest("lblTest", &page);
page.RegisterVariable("lblTest_Text", lblTest.GetTextPtr());
lblTest.SetText("these contents were replaced");
auto response = createResponse(Status::CODE_200, page.render().c_str());
response->putHeader(Header::CONTENT_TYPE, "text/html");
return response;
}
"Code-Beside"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta charset="utf-8" />
<title>GridIron Test Page</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<h2>GridIron Test Page</h2>
<hr/>
<table border="0" cellpadding="5" cellspacing="5">
<tr>
<th align="left" bgcolor="#dedede" colspan="2">Variable Replacement:</th>
</tr>
<tr>
<td align="left"><b>Front Page (no spaces):</b></td>
<td align="left"><%=__frontpage%></td>
</tr>
<tr>
<td align="left"><b>Front Page File (no spaces):</b></td>
<td align="left"><%=__frontpage_file%></td>
</tr>
<tr>
<th align="left" bgcolor="#dedede" colspan="2">Variable Replacement:<br>
<small>This will not render unless you configured with --enable-vartag-spaces</small></th>
</tr>
<tr>
<td align="left"><b>Front Page (with spaces):</b></td>
<td align="left"><%= __frontpage %></td>
</tr>
<tr>
<td align="left"><b>Front Page File (no spaces):</b></td>
<td align="left"><%= __frontpage_file %></td>
</tr>
<tr>
<th align="left" bgcolor="#dedede" colspan="2">gi::Label Test<br>
<small>This will show "default contents" if SetText did not work</small></th>
</tr>
<tr>
<td align="left" colspan="2">
<gi::Label id="lblTest">default contents</gi::Label>
</td>
</tr>
<tr>
<th align="left" bgcolor="#dedede" colspan="2">Variable Replacement with text from lblTest:</th>
</tr>
<tr>
<td align="left"><b>lblTest.Text:</b></td>
<td align="left"><%=lblTest_Text%></td>
</tr>
<tr>
<th align="left" bgcolor="#dedede" colspan="2">Autonomous gi::Label Test<br>
<small>This should show "default auto contents".</small></th>
</tr>
<tr>
<td align="left" colspan="2">
<gi::Label auto="true" id="lblAutoTest">default auto contents</gi::Label>
</td>
</tr>
<tr>
<th align="left" bgcolor="#dedede" colspan="2">Variable Replacement with text from lblAutoTest:</th>
</tr>
<tr>
<td align="left"><b>lblAutoTest.Text:</b></td>
<td align="left"><%=lblAutoTest.Text%></td>
</tr>
</table>
<a href="swagger/ui">Checkout Swagger-UI page</a>
</body>
</html>
Sample output/test-page