1.0.0 • Published 4 years ago
ifo v1.0.0
IFO - HTML if else statements!
What is the use of IFO?
Ifo allows you to embed if else statements just like javascript ones right into your HTML document!
Import
<!-- Using UNPKG -->
<script src="https://unpkg.com/ifo@latest/ifo.min.js"></script>
<!-- Using NPM -->
<script src="path/to/node_modules/ifo/ifo.min.js"></script>
IMPORTANT - Remember to import the script and the very end of the body or the variables won't be imported into if else condtions!
Syntax
Place this in your html body
<if condition="condition goes here (in javascript syntax)">
<!-- HTML code to render when the condition is TRUE here -->
</if>
<else>
<!-- HTML code to render when the condition is FALSE here -->
</else>
Example
In your HTML body:
<if condition="a === 1">
<h1>A is 1!</h1>
</if>
<else>
<h1>A is not 1!</h1>
</else>
<!-- Defining "a" as 1 -->
<script>
const a = 1;
</script>
<script src="https://unpkg.com/ifo@latest/ifo.min.js"></script>
This will give:
An h1 element with content A is 1!
as a === 1
gives boolean true
.
1.0.0
4 years ago