[go: up one dir, main page]

Skip to content

using the C Preprocessor as an HTML templating engine

Notifications You must be signed in to change notification settings

cedric-h/c-website

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published