DEV Community

Utsav Ladani
Utsav Ladani

Posted on

Simple idea of html view engine

What is html view engine?

some code that can combine multiple .html files and produce single .html file.

Let's take example.
This is index.html file

<html lang="en">
<head>
    <title>Hi hello</title>
    <link rel="stylesheet" href="./style.css">
</head>
<body>
    { navbar }
    { footer }
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

here { footer } means HTML-Engine put the code from footer.html and after replace this all { something }, engine merge all code in one file.

and this is the simple navbar.html

<nav>
    <span class="logo" >
        Logo
    </span>
    <span >
        <span>Home</span>
        <span>Student</span>
        <span>Developer</span>
        <span>About</span>
    </span>
</nav>
Enter fullscreen mode Exit fullscreen mode

and this is simple footer.html

<footer >
    Made with Utsav Ladani
</footer>
Enter fullscreen mode Exit fullscreen mode

After run my code you get this main.html

<html lang="en">
<head>
    <title>Hi hello</title>
</head>
<body>
    <nav>
    <span class="logo" >
        Logo
    </span>
    <span >
        <span>Home</span>
        <span>Student</span>
        <span>Developer</span>
        <span>About</span>
    </span>
    </nav>
    <footer >
        Made with Utsav Ladani
    </footer>
</body>

</html>
Enter fullscreen mode Exit fullscreen mode

I try to understand how html engine works, and make this simple html engine. I hope you also understand this idea.

Here is my github project link

HTML Engine

The simple engine idea which can combine multiple html file and produce a single html file. 😄

Version v1.0.0

This version is the basic idea of HTML engine.

How to use?

Use views folder as your working directory. Example is given in there. Just type node src/index.js in command line. And see the result in build/main.html.

Top comments (0)