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

If then else branches

The if then else construct is defined by the ul element. This element must have exactly two or three branches (condition, if branch and optional else branch). This code:

<ul>
    <strong id="==">
        <p id="foo"></p>
        <p id="10"></p>
    </strong>
    <if>
        <p>Some code here</p>
    </if>
    <else>
        <p>Some other code here</p>
    </else>
</ul>

is compiled as:

if(foo == 10){
    'Some code here';
}
else{
    'Some other code here';
}

The element <strong> will be explained in details later, but it stands for a comparison. Please note that condition, if and else branches must be declared in this exact order.

PreviousValue assignmentNextComparison and logical operators

Last updated 4 years ago

Was this helpful?