HTPL Compiler
  • HTPL Compiler
  • Introduction
  • Github repository
  • What is HTPL and why it exists
  • Getting started
  • Syntax
    • Variable declaration
    • Returning values
    • Operations between values
    • Value assignment
    • If then else branches
    • Comparison and logical operators
    • Function declaration and invocation
    • While loop
    • Inputs and outputs
    • Comments
  • Other
    • HTPLCompiler interface - Browser
    • Error handling
Powered by GitBook
On this page

Was this helpful?

  1. Syntax

Function declaration and invocation

A function can be declared with the <div> element. Function name is specified by the id, and optional parameters are specified by the classes of the element:

<div id="anakinSays" class="name, age">
    <return>
        <p>This is were the fun begins</p>
    </return>
</div>

this is compiled as:

function anakinSays(name, age){
    return 'This is were the fun begins';
}

Classes can be omitted if function does not require any parameters. Also <return> can be omitted to make a void function.

Functions can be invoked with <h3> tag. Function name must be specified with the id (without brackets) and all the children are considered parameters:

<h3 id="anakinSays">
    <p>Andrea</p>
    <p id="19"></p>
</h3>

is compiled as:

anakinSays('Andrea', 19);
PreviousComparison and logical operatorsNextWhile loop

Last updated 4 years ago

Was this helpful?