An open API service indexing awesome lists of open source software.

https://github.com/lucthienphong1120/html-is-a-programming-language

HTML Is A Programming Language
https://github.com/lucthienphong1120/html-is-a-programming-language

discussion html html-program html-template htmlproject htmltips topic

Last synced: about 1 year ago
JSON representation

HTML Is A Programming Language

Awesome Lists containing this project

README

          

# HTML Is A Programming Language

The following material is taken from a research project by an expert to end the eternal discusion.

## Language Overview

To avoid introducing a parser for arithmetic/comparison/logic expressions I did
what any sensible person would do, create a stack language hybrid.

### Character

It is a single character. (`a-z,@,#,$,%,^,&,*,...`)

### Numbers

`1, 2, 3, 4, 5, 6, 7, 8, 9, 0`

### Booleans

`true`, `false`

### Variables

`$foo`, `$bar`

### Strings

Anything that is not character value is considered a string, no quotes needed

## Language Constructs

### v

Put the value in the document

Example: put the value of variable `$i` in the document

``

### let

Binds variables to values (see literals above), for example:

```html

String:


Number:


Boolean:


Variable:

```

Will generate:

```html
String: hello

Number: 4

Boolean: true

Variable: hello
```

### cond

Evaluate conditions in order, return the body of the first that matches or `else` if
present and no other `if` matches

```html

FizzBuzz

Fizz

Buzz

```

Note: any other HTML tags or expressions are evaluated if present inside `cond` until
the first if/else match, for example:

```html






FizzBuzz

Fizz

Buzz

```

### if

Embed the tag's body if the condition evaluates to true.

Note: can be used inside cond where if true stops evaluating conditions (like if/else
if) or outside where it works like a single if without else if/else branches.

### else

Embed the tag's body if the tag is reached inside a `cond` tag.

Note: if used outside a `cond` it will always embed its body.

### for

Binds each item in an iterator to a variable and embeds the body of the `for` tag
as many times as items in the iterator with the item bound to the provided variable.

```html

```

### defn

Define a function that can later be called with the `do` tag.

```html





```

### do

Call a function with a name and 0 or more parameters

Push value in variable `$i` to the stack: ``
Push number 3 to the stack: ``
Call reminder (takes 2 values from the stack and pushes the result): ``

Call user defined function `calc-is-mod` passing variable `$i` and number `3` as parameter: ``

### nb

A [comment](https://dictionary.cambridge.org/dictionary/english/nb) whose body is logged to the console

`i = i % 3 == 0? ` will print something like `i = 1 i % 3 == 0? false` to the console

## Examples

### Simple Fizzbuzz

```html







i = i % 3 == 0?







i = i % 4 == 0?





i = i % 3 == 0 and i % 4 == 0?


FizzBuzz

Fizz

Buzz


```

### Fizzbuzz with Functions

```html










i = i % 3 == 0?



i = i % 4 == 0?





i = i % 3 == 0 and i % 4 == 0?


FizzBuzz

Fizz

Buzz



```

### Counter

A counter with two buttons, one to increment and one to decrement, the counter markup
is:

```html
-

+
```

```html






```