A library for building HTML.

Installs: 36

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0


2.0.0 2016-07-08 12:53 UTC

This package is not auto-updated.

Last update: 2021-10-20 04:16:03 UTC


A library for building HTML.

Basic Usage

# in Javascript!
var factory = new lucid.html.factory();
var myAnchor = factory.build('anchor', 'http://google.com', 'google');
# in PHP!
# (this assumes you've configured an autoloader to find this class)
$factory = new \Lucid\Html\Factory();
$myAnchor = $factory->build('anchor', 'http://google.com', 'google');

Both of these code samples will log/echo this:

<a href="http://google.com">google</a>

Building and Testing

Building all tags and running tests

There's one main script that does pretty much everything you'll need to do to change the source, package it up, and test it:


This does the following:

  1. Builds all tags (See sections below)
  2. Packages up all Javascript files (See sections below)
  3. Loads the final javascript files in node just to do one final syntax check
  4. Runs all unit tests

This library uses phpunit to run unit tests, but additionally runs javascript tests through phpunit by calling node.js through shell_exec. So in order to run unit tests, you must install node. You will also have to use composer before running tests as the tests use composer's autoloader.

Building Tags

Every tag in the library is generated using a json file that describes the tag. To generate the javascript tag for the base anchor tag,

bin/makeTagJavascript.php ./src/Base/meta/anchor.json
 # This will generate ./src/Base/tags/anchor.js

To generate the PHP tag for the base anchor tag,

bin/makeTagPHP.php ./src/Base/meta/anchor.json
 # This will generate ./src/Base/tags/anchor.php

To build all tags in a meta folder:

bin/makeAllTags ./src/Base/meta
 # this builds everything!

Packing up Javascript files for distribution


This will generate four files:

  1. ./dist/lucid.html.buildBaseTagsOnly.js
  2. ./dist/lucid.html.buildBaseTagsOnly.min.js (this is the same as the previous file, but minified)
  3. ./dist/lucid.html.buildBootstrap.js
  4. ./dist/lucid.html.buildBootstrap.min.js (this is the same as the previous file, but minified)

In a project, only one of those 4 files needs to be included.