cedric-h / c-website

using the C Preprocessor as an HTML templating engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

using the C preprocessor as an HTML templating engine

example:

header.html

    <head>
        <meta charset="utf-8" />
        <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>πŸ“œ</text></svg>">
        <title>ced.quest βš”οΈ </title>
        <style>
        </style>
    </head>

index.template.html

<!DOCTYPE html>
<html lang="en">
#include "header.html"

    <body>
        <p> hi ben! </p>
    </body>
</html>

command:

cpp -P index.template.html index.html

note: cpp is "C Preprocessor," comes with GCC installs.

-P inhibits the output of linemarkers, which may be useful for debugging complicated macros. (please do not make complicated macros)

it is noted here that cl \P \EP works to accomplish this with MSVC.

index.html (output)

<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="utf-8" />
        <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>πŸ“œ</text></svg>">
        <title>ced.quest βš”οΈ </title>
        <style>
        </style>
    </head>


    <body>
        <p> hi ben! </p>
    </body>
</html>

About

using the C Preprocessor as an HTML templating engine


Languages

Language:Python 56.9%Language:HTML 43.1%