Skip to content
/ HTPL Public

A tag-based programming language inspired by HTML, designed to make markup actually programmable.

License

Notifications You must be signed in to change notification settings

DrelezTM/HTPL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

HyperText Programming Language - HTPL

@htpl

HyperText Programming Language

Stop arguing if HTML is a programming language.. here's HTPL ๐Ÿ˜Ž

Introducing โ‰๏ธ

HTPL was born from one eternal internet debate:

"Is HTML a programming language or not?"

Instead of arguing forever... I decided to just build one. So here it is.

HyperText Programming Language (HTPL): looks like HTML, but actually behaves like a real programming language.

Installation ๐Ÿ“‘

git clone https://github.com/DrelezTM/HTPL.git
cd HTPL
npm install

Running ๐Ÿš€

node bin/htpl.js <file.htpl>

Run Command Example:

node bin/htpl.js example/looping.htpl

Example ๐Ÿ‘€

Code:

<htpl>
    <input name="name" prompt="Enter your name = "/>
    <output message="Hi {{ name }}! welcome to HyperText Programming Language!"/>
</htpl>

Response: image

Want to see more cool HTPL programs and play with other example files? Check them out here

Command ๐Ÿ—๏ธ

HTPL is like HTML, but itโ€™s not a markup language - itโ€™s just for fun! It supports variables, loops, conditions, functions, input/output, and basic control flow.

Assign and Reassign Variable

<set name="foo" value="'hello world'" />
<set name="bar" value="123" />
let foo = "hello world";
const bar = 123;

Input

<input name="username" prompt="Enter your name: " />
const readline = require('readline-sync');
const username = readline.question("Enter your name: ");

Output

<output message="Hello {{ username }}" />
console.log(`Hello ${username}`);

Conditional (If/Else)

<if condition="foo == 'hello'">
    <output message="It's hello!" />
</if>
<if condition="foo != 'hello'">
    <output message="Not hello." />
</if>
if(foo == "hello"){
    console.log("It's hello!");
} else {
    console.log("Not hello.");
}

Loops

<for var="i" from="0" to="5">
    <output message="Loop number {{ i }}" />
</for>
for (let i = 0; i < 5; i++){
    console.log("Loop number " + i);
}

Break/Continue

<for var="i" from="0" to="5">
    <if condition="i == 3">
        <break />
    </if>
</for>
for (let i = 0; i < 5; i++){
    if(i == 3) break;
}

Define Function

<function name="greet" params="firstname,lastname">
    <output message="Hello {{ firstname }}" />
    <output message="Hi {{ lastname }}" />
</function>
function greet(firstname, lastname){
    console.log(`Hello ${firstname}`);
    console.log(`Hi ${lastname}`);
}

Call Function

<call name="greet" args="'Yazid', 'Yusuf'"/>
greet("Yazid", "Yusuf");

Important โš ๏ธ

Every HTPL program must be wrapped inside <htpl> โ€ฆ </htpl>.

For example:

<htpl>
    <!-- Your HTPL code goes here -->
    <set name="foo" value="'hello world'"/>
    <output message="Hello {{ foo }}"/>
</htpl>
  • The tag is the root of your program.
  • All variables, loops, functions, input/output must be inside this root tag.
  • If you forget it, the interpreter will not run your code.

Think of as the "main container" for your program - everything lives inside it. ๐Ÿš€

Disclaimer ๐Ÿšง

This project is made for fun, learning, and experimenting with interpreter concepts.
It is not production-ready - please donโ€™t use it for serious systems ๐Ÿ˜…

Feel free to fork it, improve it, or build your own HTPL!

Language ๐ŸŒ

Error or Bug ๐Ÿž

License ๐Ÿ“œ

About

A tag-based programming language inspired by HTML, designed to make markup actually programmable.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published