Buffered function-based HTML generator for PHP

v1.0.0-alpha2 2022-01-13 22:51 UTC

This package is auto-updated.

Last update: 2024-09-14 05:09:09 UTC


README

eq is a function library developed to make outputting HTML a breeze in PHP

the basics

eq has buffered output, meaning that it doesn't actually dump what you've created until you tell it to.

All eq documents start with eq_start(); and end with eq_end();

With eq, we can generate HTML that looks like this ⏬

<!DOCTYPE html>
<html>
<head>
<title>eq.php</title>
<meta name="description" content="example eq page">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="prism.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
</body>
</html>

from a script that looks like this ⏬

eq_start("eq_title=eq.php",["description", "example eq page"], "style.css", "prism.css", "https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js");
eq_end();

We can add HTML elements after we've called eq_start() by using a plethora of functions

head content

Head information can be added inside of eq_start(), or separately from individual function calls as-needed.

eq_start()

accepts a range of arguments - as seen in the example above, linked items (CSS files, JS files) will automatically import to the head section if listed in the arguments of this function.

meta tags can be included in an eq_start call by listing them as an array, ie, eq_start(["description", "example eq page"]) would give you <meta name="description" content="example eq page"> (it's worth noting that cases are registered not only for standard pattern-breaking meta tags, i.e. ["UTF-8"] as <meta charset=UTF-8>, but also for non-standard meta tags such as og:, fb:, and article: that return property rather than name)

Some items need to be better defined - specifically styles and scripts that are not linked (eg, eq_start("eq_style=.cssclass { background-color: #000; }") or eq_start("eq_script=alert('Hello World!');")) the title of the page can be defined in eq_start() by using "eq_title=This Is A Website!"

With all of the aforementioned cases, you can instead use one of the functions below and omit it from your eq_start arguments.

Reference

context-based head functions

these functions will act differently depending on if you've already added body content or not

body content

Reference