shawnholman/Aych

View on GitHub
docs/index.html

Summary

Maintainability
Test Coverage
<!doctype html>
<html class="default no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Aych</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<header>
    <div class="tsd-page-toolbar">
        <div class="container">
            <div class="table-wrap">
                <div class="table-cell" id="tsd-search" data-index="assets/js/search.js" data-base=".">
                    <div class="field">
                        <label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
                        <input id="tsd-search-field" type="text" />
                    </div>
                    <ul class="results">
                        <li class="state loading">Preparing search index...</li>
                        <li class="state failure">The search index is not available</li>
                    </ul>
                    <ul class="results-priority" style="display:none">
                    </ul>
                    <a href="index.html" class="title">Aych</a>
                </div>
                <div class="table-cell" id="tsd-widgets">
                    <div id="tsd-filter">
                        <a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
                        <div class="tsd-filter-group">
                            <div class="tsd-select" id="tsd-filter-visibility">
                                <span class="tsd-select-label">All</span>
                                <ul class="tsd-select-list">
                                    <li data-value="public">Public</li>
                                    <li data-value="protected">Public/Protected</li>
                                    <li data-value="private" class="selected">All</li>
                                </ul>
                            </div>
                            <input type="checkbox" id="tsd-filter-inherited" checked />
                            <label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
                        </div>
                    </div>
                    <a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
                </div>
            </div>
        </div>
    </div>
    <div class="tsd-page-title">
        <div class="container">
            <ul class="tsd-breadcrumb">
            </ul>
        </div>
    </div>
</header>
<div class="container container-main">
    <div class="row">
        <div class="col-3 col-menu menu-sticky-wrap menu-highlight">
            <nav class="tsd-navigation outline primary">
                <a style="margin-left:0em" href="globals.html">Globals</a>
                <ul style="display:none">
                    {&quot;Library&quot;:{&quot;H&quot;:&quot;_h_&quot;,&quot;Aych&quot;:&quot;classes/_core_aych_.aych&quot;},&quot;Core&quot;:{&quot;Piper&quot;:&quot;classes/_core_piper_.piper&quot;,&quot;Renderable&quot;:&quot;classes/_core_renderable_.renderable&quot;,&quot;StringLiteral&quot;:&quot;classes/_core_stringliteral_.stringliteral&quot;},&quot;Elements&quot;:{&quot;Element&quot;:&quot;classes/_elements_element_.element&quot;,&quot;EmptyElement&quot;:&quot;classes/_elements_emptyelement_.emptyelement&quot;,&quot;NestableElement&quot;:&quot;classes/_elements_nestableelement_.nestableelement&quot;},&quot;Interfaces&quot;:{&quot;Attributes&quot;:&quot;interfaces/_interfaces_attributes_.attributes&quot;,&quot;RenderOptions&quot;:&quot;interfaces/_interfaces_render_options_.renderoptions&quot;,&quot;SimpleObject&quot;:&quot;interfaces/_interfaces_simple_object_.simpleobject&quot;},&quot;Structural&quot;:{&quot;Each&quot;:&quot;classes/_structural_each_.each&quot;,&quot;If&quot;:&quot;classes/_structural_if_.if&quot;,&quot;Switch&quot;:&quot;classes/_structural_switch_.switch&quot;,&quot;Group&quot;:&quot;classes/_structural_group_.group&quot;}}
                </ul>
            </nav>
        </div>
        <div class="col-7 offset-3 col-content">
            <h1>Aych</h1>
            <div class="tsd-panel tsd-typography">
                <a href="#aych" id="aych" style="color: inherit; text-decoration: none;">
                    <h1>Ayc[H]</h1>
                </a>
                <p>A javascript library for writing eloquent HTML to create dynamic webpages without
                the bells and whistles of a framework.</p>
                <p><a href="https://travis-ci.com/github/shawnholman/Aych"><img src="https://travis-ci.com/shawnholman/Aych.svg?token=593S1dXVHUzTznXmMuYA&branch=master&status=created" alt="build"></a>
                    <a href="https://codecov.io/gh/shawnholman/Aych"><img src="https://img.shields.io/codecov/c/github/shawnholman/aych/master?token=XLW5V9O2CF" alt="coverage"></a>
                <a href="https://codeclimate.com/github/shawnholman/Aych/maintainability"><img src="https://api.codeclimate.com/v1/badges/b154a8ee535354814515/maintainability" alt="Maintainability"></a></p>
                <a href="#overview" id="overview" style="color: inherit; text-decoration: none;">
                    <h2>Overview</h2>
                </a>
                <p>Writing HTML inside of JavaScript has been a pain for many years for myself. With today’s
                    technologies, you are either stuck with a blob of HTML inside of your JavaScript, you rely
                    on heavy templating engines that hardly make anything better, or you use a framework.
                    Aych solves a decade old problem in a new way and
                    make dynamic HTML independent of large frameworks that do the heavy lifting. Aych provides
                    a micro-library to facilitate writing eloquent HTML inside of JavaScript.
                It’s that simple, but very powerful.</p>
                <a href="#example-usage" id="example-usage" style="color: inherit; text-decoration: none;">
                    <h2>Example Usage</h2>
                </a>
                <p>The following is an example of one way Aych can be used. See the <code>tests</code> (<a href="https://github.com/shawnholman/Aych/tree/master/tests">github/Aych/tests</a>) folder for a comprehensive set of examples.</p>
                <a href="#using-aych" id="using-aych" style="color: inherit; text-decoration: none;">
                    <h4>Using Aych:</h4>
                </a>
                <pre><code class="language-javascript">H.$(({ div, row, $if, $eachIn, span }) =&gt; {
    <span class="hljs-keyword">return</span> div(<span class="hljs-string">&#x27;#example.row.view-badge-info&#x27;</span>,
        $if(!data.badge.isActive,
            div(<span class="hljs-string">&#x27;.row.text-center.inactive-badge&#x27;</span>, <span class="hljs-string">&#x27;Disabled Badge&#x27;</span>)
        ),
        div(<span class="hljs-string">&#x27;.col.col-xs-7.col-sm-7.col-md-7.text-left&#x27;</span>,
            row(<span class="hljs-string">&#x27;Name&#x27;</span>, <span class="hljs-string">&#x27;{{user.name}}&#x27;</span>),
            row(<span class="hljs-string">&#x27;Email&#x27;</span>, <span class="hljs-string">&#x27;{{user.email}}&#x27;</span>),
            row(<span class="hljs-string">&#x27;Points&#x27;</span>, <span class="hljs-string">&#x27;{{user.points}}&#x27;</span>),
            $eachIn(data.user.application,
                row(<span class="hljs-string">&#x27;{{item[0]|unCamelCase}}&#x27;</span>, <span class="hljs-string">&#x27;{{item[1]}}&#x27;</span>)
            )
        ),
        div(<span class="hljs-string">&#x27;.col.col-xs-5.col-sm-5.col-md-5.text-right&#x27;</span>,
            $eachIn(data.user.is, <span class="hljs-function">(<span class="hljs-params">[name, value]</span>) =&gt;</span>
                row(
                    H.string(<span class="hljs-string">&#x27;{{name|unCamelCase}}&#x27;</span>).render({name}),
                    span(<span class="hljs-string">&#x27;.permission-circle&#x27;</span>, {<span class="hljs-attr">class</span>: [value, <span class="hljs-string">&#x27;+granted&#x27;</span>, <span class="hljs-string">&#x27;+denied&#x27;</span>]})
                )
            )
        )
    )
}, data);</code></pre>
                <a href="#where-the-data-are" id="where-the-data-are" style="color: inherit; text-decoration: none;">
                    <h4>where the data are:</h4>
                </a>
                <pre><code class="language-javascript"><span class="hljs-keyword">const</span> data = {
    <span class="hljs-attr">badge</span>: {
        <span class="hljs-attr">isActive</span>: <span class="hljs-literal">false</span>,
    },
    <span class="hljs-attr">user</span>: {
        <span class="hljs-attr">name</span>: <span class="hljs-string">&#x27;John Doe&#x27;</span>,
        <span class="hljs-attr">email</span>: <span class="hljs-string">&#x27;john doe@gmail.com&#x27;</span>,
        <span class="hljs-attr">points</span>: <span class="hljs-number">0</span>,
        <span class="hljs-attr">application</span>: {
            <span class="hljs-attr">school</span>: <span class="hljs-string">&#x27;UGA&#x27;</span>,
            <span class="hljs-attr">grade</span>: <span class="hljs-string">&#x27;Freshman&#x27;</span>,
            <span class="hljs-attr">hometown</span>: <span class="hljs-string">&#x27;Atlanta&#x27;</span>,
            <span class="hljs-attr">gradePointAverage</span>: <span class="hljs-string">&#x27;4.0&#x27;</span>,
        },
        <span class="hljs-attr">is</span>: {
            <span class="hljs-attr">admin</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-attr">volunteer</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-attr">organizer</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-attr">owner</span>: <span class="hljs-literal">false</span>,
        },
    },
};</code></pre>
                <a href="#results-in-the-following-html" id="results-in-the-following-html" style="color: inherit; text-decoration: none;">
                    <h4>results in the following html:</h4>
                </a>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;example&quot;</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row view-badge-info&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row text-center inactive-badge&quot;</span>&gt;</span>Disabled Badge<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col col-xs-7 col-sm-7 col-md-7 text-left&quot;</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Name<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: John Doe
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Email<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: johndoe@gmail.com
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Points<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: 0
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>School<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: UGA
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Grade<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: Freshman
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Hometown<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: Atlanta
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Grade Point Average<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: 4.0
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col col-xs-5 col-sm-5 col-md-5 text-right&quot;</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Admin<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;permission-circle denied&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Volunteer<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;permission-circle granted&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Organizer<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;permission-circle granted&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Owner<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;permission-circle denied&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></code></pre>
                <a href="#downloading" id="downloading" style="color: inherit; text-decoration: none;">
                    <h2>Downloading</h2>
                </a>
                <p>In order to use Aych, download <a href="https://github.com/shawnholman/Aych/tree/master/dist">aych.min.js</a> from the dist folder and load with:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text/javascript&quot;</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;aych.min.js&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre>
                <p>#Documentation
                    Aych is a library that is meant to stay slim and simple. This documentation should give you a good understanding of
                Aych.</p>
                <ul>
                    <li><a href="#globals">Globals</a><ul>
                            <li><a href="#conflict">Conflict</a></li>
                        </ul>
                    </li>
                    <li><a href="#renderable">Renderable</a></li>
                    <li><a href="#tags">Tags</a><ul>
                            <li><a href="#attributes">Attributes</a><ul>
                                    <li><a href="#identifier-string">Identifier String</a></li>
                                    <li><a href="#other-attributes">Other Attributes</a>  </li>
                                </ul>
                            </li>
                            <li><a href="#empty-elements">Empty Elements</a></li>
                            <li><a href="#nestable-elements">Nestable Elements</a></li>
                            <li><a href="#string-literals">String Literals</a></li>
                        </ul>
                    </li>
                    <li><a href="#rendering">Rendering</a><ul>
                            <li><a href="#rendertemplates-options">.render(templates, options)</a><ul>
                                    <li><a href="#templating">Templating</a></li>
                                    <li><a href="#options">Options</a></li>
                                </ul>
                            </li>
                            <li><a href="#r">.r</a></li>
                            <li><a href="#tostring">.toString()</a></li>
                        </ul>
                    </li>
                    <li><a href="#piper">Piper</a></li>
                    <li><a href="#statements">Statements</a><ul>
                            <li><a href="#-scope">$</a></li>
                            <li><a href="#if">$if</a></li>
                            <li><a href="#each">$each</a></li>
                            <li><a href="#eachin">$eachIn</a></li>
                            <li><a href="#repeat">$repeat</a></li>
                            <li><a href="#group">$group</a></li>
                            <li><a href="#switch--case">$switch / $case</a></li>
                        </ul>
                    </li>
                    <li><a href="#more-examples">More Examples</a></li>
                </ul>
                <a href="#globals" id="globals" style="color: inherit; text-decoration: none;">
                    <h2>Globals</h2>
                </a>
                <p>To start off, Aych has two exposed globals: <code>Aych</code> and <code>H</code>. These are homonyms. <code>Aych</code> is the core of the library
                while <code>H</code> is an instantiation of <code>Aych</code>. Their purposes are different, though.</p>
                <p><code>Aych</code> is used to:</p>
                <ol>
                    <li>Add/Remove Tags</li>
                    <li>Add/Remove Compositions</li>
                    <li>Access Piper</li>
                </ol>
                <p><code>H</code> is used to:</p>
                <ol>
                    <li>Create HTML Tags</li>
                    <li>Call Statements</li>
                </ol>
                <a href="#conflict" id="conflict" style="color: inherit; text-decoration: none;">
                    <h3>Conflict</h3>
                </a>
                <p>Because <code>H</code> is just an instantiation of <code>Aych</code>, you can easily reassign it. Likewise, you can reassign <code>Aych</code> itself.</p>
                <a href="#renderable" id="renderable" style="color: inherit; text-decoration: none;">
                    <h2>Renderable</h2>
                </a>
                <p>The term renderable is very important in understanding the rest of the documentation. A renderable is the foundational
                    logic for renderable child class to inherit and use. A renderable, conceptually, is a class that has a render method
                    that can be called to get a string representation of that class. Almost all functions under <code>H</code> will return a
                renderable which supports the following API:</p>
                <ul>
                    <li>render(templates, options): Renders a renderable with templates and options set.</li>
                    <li>with(templates): Sets the templates of the renderable</li>
                    <li>when (condition): Turns on and off renderability of the renderable.</li>
                    <li>get r(): Getter that calls the render method without templates or options. </li>
                    <li>toString(): Called when the renderable is converted to a string. Also calls the render method without templates or
                    options. </li>
                </ul>
                <a href="#tags" id="tags" style="color: inherit; text-decoration: none;">
                    <h2>Tags</h2>
                </a>
                <p>At the core of Aych, you want to be able to create HTML Tags. These tags follow the same naming conventions as the HTML
                tags themselves and live under <code>H</code>.</p>
                <p>For example:</p>
                <pre><code class="language-javascript">H.span().r; </code></pre>
                <p>Produces:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span></code></pre>
                <p><code>H.span()</code> returns a renderable and such needs to be resolved to a string using one of three ways to render:</p>
                <ol>
                    <li>.render();</li>
                    <li>.r; <strong>(unsed in the example above)</strong></li>
                    <li>.toString(); (or anything that would cause toString to automatically call such as <code>+ &quot;&quot;</code>;</li>
                </ol>
                <p>More on rendering later.</p>
                <p>Of course, HTML is a bit more complicated than a single span. This section will cover how to add attributes and
                children to the elements.</p>
                <a href="#attributes" id="attributes" style="color: inherit; text-decoration: none;">
                    <h2>Attributes</h2>
                </a>
                <p>There are many attributes in HTML but are all formatted similarly. We wanted to give a simple and easy way to add
                attributes while adding control.</p>
                <a href="#identifier-string" id="identifier-string" style="color: inherit; text-decoration: none;">
                    <h3>Identifier String</h3>
                </a>
                <p>The first thing we discovered about HTML, is that by far the most used attributes are <code>id</code> and <code>class</code>. For this reason
                we developed the identifier string which dissolves into these two attributes.</p>
                <p>The identifier string is a string you apply to the first parameter of any element. The string itself should either
                    start with a <code>#</code> (for id) or <code>.</code> (for class) and be followed up by 0 or more class names. If an id is specified, it
                must come first.</p>
                <p><strong>Identifier string should always be defined as the first parameter, but it&#39;s not require.</strong></p>
                <p>Valid:</p>
                <pre><code class="language-javascript">H.span(<span class="hljs-string">&quot;#example.hello.world&quot;</span>); </code></pre>
                <p>Produces:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;example&quot;</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;hello world&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span></code></pre>
                <p>Invalid:</p>
                <pre><code class="language-javascript">H.span(<span class="hljs-string">&quot;example.hello.world&quot;</span>); <span class="hljs-comment">// does not start with &quot;#&quot; or &quot;.&quot;</span>
H.span(<span class="hljs-string">&quot;.hello.world#example&quot;</span>); <span class="hljs-comment">// id should come first</span></code></pre>
                <p>In fact, those invalid examples would actually register the string as a literal which will result in this:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>example.hello.world<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>.hello.world#example<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span></code></pre>
                <a href="#other-attributes" id="other-attributes" style="color: inherit; text-decoration: none;">
                    <h3>Other attributes</h3>
                </a>
                <p>Every other attribute can be given in an object either in place of the identifier string or afterwards.</p>
                <p><strong>This list should always come after the identifier string (if used) and before children.</strong></p>
                <p>The following examples gives some cools ways that the attribute object can be used to help manipulate attributes.</p>
                <p>For example:</p>
                <pre><code class="language-javascript">H.span(<span class="hljs-string">&quot;#example.hello.world&quot;</span>, {
    <span class="hljs-comment">// Add the style attribute with given value.</span>
    <span class="hljs-string">&quot;style&quot;</span>: <span class="hljs-string">&quot;color: red&quot;</span>,

    <span class="hljs-comment">// Append / remove classes (remove with &#x27;-&#x27; instead of &#x27;+&#x27;)</span>
    <span class="hljs-string">&quot;class&quot;</span>: <span class="hljs-string">&#x27;+awesome&#x27;</span>,

    <span class="hljs-comment">// Add an attribute with a conditional value.</span>
    <span class="hljs-string">&quot;lang&quot;</span>: [<span class="hljs-literal">true</span>, <span class="hljs-string">&quot;en-US&quot;</span>, <span class="hljs-string">&#x27;en-UK&#x27;</span>],

    <span class="hljs-comment">// Conditionally append/remove classes</span>
    <span class="hljs-string">&quot;class&quot;</span>: [<span class="hljs-literal">false</span>, <span class="hljs-string">&#x27;+cool&#x27;</span>, <span class="hljs-string">&#x27;-world&#x27;</span>],

    <span class="hljs-comment">// Includes attribute:</span>
    <span class="hljs-string">&quot;title&quot;</span>: [<span class="hljs-literal">true</span>, <span class="hljs-string">&quot;a span&quot;</span>],

    <span class="hljs-comment">// Excluse attribute</span>
    <span class="hljs-string">&quot;data-attr&quot;</span>: [<span class="hljs-literal">false</span>, <span class="hljs-string">&quot;value&quot;</span>],
}); </code></pre>
                <p>Produces:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;example&quot;</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;hello awesome&quot;</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;color: red;&quot;</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;en-US&quot;</span> <span class="hljs-attr">title</span>=<span class="hljs-string">&quot;a span&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span></code></pre>
                <a href="#empty-elements" id="empty-elements" style="color: inherit; text-decoration: none;">
                    <h3>Empty Elements</h3>
                </a>
                <p>An empty element cannot have nested elements inside of it. An example of this is the HTML tag: <code>input</code>. The tag cannot
                accept children. Empty elements in Aych should be treated the same way.</p>
                <pre><code class="language-javascript">H.input().r; </code></pre>
                <p>Produces:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">input</span>&gt;</span></code></pre>
                <a href="#nestable-elements" id="nestable-elements" style="color: inherit; text-decoration: none;">
                    <h3>Nestable Elements</h3>
                </a>
                <p>A nestable element can have nested elements inside of it. The majority of HTML tags are nestable like: <code>span</code>, <code>div</code>,
                <code>strong</code>, etc.</p>
                <p>For example:</p>
                <pre><code class="language-javascript">H.span(H.div(), H.strong()).r; </code></pre>
                <p>Produces:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span></code></pre>
                <p>In this case, we have <code>div</code> and <code>strong</code> tags nested inside of the single span. This is reflected in Aych by using the
                power of variable arguments. We could add any number of elements within these parentheses. </p>
                <p>This more complex example:</p>
                <pre><code class="language-javascript">H.span(<span class="hljs-string">&quot;.class1&quot;</span>, { <span class="hljs-string">&quot;data-value&quot;</span>: <span class="hljs-string">&quot;somevalue&quot;</span> },
    H.div(H.strong(<span class="hljs-string">&quot;#id.class2&quot;</span>, <span class="hljs-string">&quot;Hi&quot;</span>)), 
    H.strong(H.div(H.strong(<span class="hljs-string">&quot;Buddy&quot;</span>)))
).r; </code></pre>
                <p>Produces:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;class1&quot;</span> <span class="hljs-attr">data-value</span>=<span class="hljs-string">&quot;somevalue&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;id&quot;</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;class2&quot;</span>&gt;</span>Hi<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Buddy<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span></code></pre>
                <p>As you can see, the parameters for every attribute is flexible and follows these rules:</p>
                <ol>
                    <li>Identifier string has to be the first parameter and valid. Otherwise, it will be a literal.</li>
                    <li>Attribute has to follow identifier string but preceed children. </li>
                    <li>Children must come after identifier string and attributes.</li>
                </ol>
                <p><code>1</code> is very important because a malformed identifier string could lead to unexpected errors as it would be treated
                as a child meaning that attributes followed by a child would lead to this error.</p>
                <p>Maybe you can also tell that the children were not explicitly rendered using &#39;.r&#39;. Only the <code>span</code> is rendered.
                    This is by design as rendering bubbles down to the children. In fact, rendering the children will cause unexpected
                    results because the string returned by &quot;.r&quot; would be read as a literal, and the HTML produced by it escaped by the
                parent.</p>
                <a href="#string-literals" id="string-literals" style="color: inherit; text-decoration: none;">
                    <h3>String Literals</h3>
                </a>
                <p>Aych supports printing string literals within tags. Any stringable type can be used as a string literal including
                numbers and arrays.</p>
                <p>String literals can be used directly in Aych as children as they are considered renderable. You can also use
                    <code>Aych.string()</code> to create a string literal. String literals should not contain any HTML as it will be escaped
                    automatically. If you would like a string literal that does not have this functionality, you can use <code>Aych.unescape()</code>
                in place of using a string literal or <code>Aych.string()</code>.</p>
                <p>These string literals also support a simple templating that can pull data from the templates passed in through
                the render method. More on that in the render section. However, this would look like this:</p>
                <pre><code class="language-javascript">H.string(<span class="hljs-string">&quot;{{name}}&quot;</span>).render({ <span class="hljs-attr">name</span>: <span class="hljs-string">&#x27;John&#x27;</span> }); <span class="hljs-comment">// output: &quot;John&quot;</span></code></pre>
                <a href="#rendering" id="rendering" style="color: inherit; text-decoration: none;">
                    <h2>Rendering</h2>
                </a>
                <p>Rendering in aych is the process of turning a function into it&#39;s HTML equivalence. Rendering can be done in three ways:</p>
                <ol>
                    <li>.render(templates, options)</li>
                    <li>.r</li>
                    <li>.toString();</li>
                </ol>
                <a href="#rendertemplates-options" id="rendertemplates-options" style="color: inherit; text-decoration: none;">
                    <h3>.render(templates, options);</h3>
                </a>
                <p>The most powerful way to render is with the <code>render</code> method which allows you to pass in templates and options for the
                rendering. Template data can be used inside of string literals to conveniently access data.</p>
                <a href="#templating" id="templating" style="color: inherit; text-decoration: none;">
                    <h4>Templating</h4>
                </a>
                <p>Aych supports a very simple templating. One of the design goals was to keep this engine very simple. It supports
                accessing data from the templating object, and it also supports piping. See the piping section for details.</p>
                <p>You can access data inside of the template string using the <code>{{ }}</code> operators with the name of the data location. Aych
                supports accessing nested objects and arrays.</p>
                <pre><code class="language-javascript">H.div(<span class="hljs-string">&quot;{{name.first[0]}} {{name.last[1]}}&quot;</span>).render({
    <span class="hljs-attr">name</span>: {
        <span class="hljs-attr">first</span>: [<span class="hljs-string">&#x27;John&#x27;</span>, <span class="hljs-string">&#x27;Billy&#x27;</span>],
        <span class="hljs-attr">last</span>: [<span class="hljs-string">&#x27;Hanks&#x27;</span>, <span class="hljs-string">&#x27;Doe&#x27;</span>]
    } 
}); <span class="hljs-comment">// output: &quot;&lt;div&gt;John Doe&lt;/div&gt;&quot;</span></code></pre>
                <p>As mentioned, there is also support for piping, or transforming the data using the pipe operator (<code>|</code>):</p>
                <pre><code class="language-javascript">H.div(<span class="hljs-string">&quot;{{name.first[0]|uppercase}} {{name.last[1]|substr(0, 1)}}&quot;</span>).render({
    <span class="hljs-attr">name</span>: {
        <span class="hljs-attr">first</span>: [<span class="hljs-string">&#x27;John&#x27;</span>, <span class="hljs-string">&#x27;Billy&#x27;</span>],
        <span class="hljs-attr">last</span>: [<span class="hljs-string">&#x27;Hanks&#x27;</span>, <span class="hljs-string">&#x27;Doe&#x27;</span>]
    } 
}); <span class="hljs-comment">// output: &quot;&lt;div&gt;JOHN d&lt;/div&gt;&quot;</span></code></pre>
                <p>As you can see, pipes can even have parameters! The substr pipe is using <code>String.prototype.substr</code>.</p>
                <a href="#options" id="options" style="color: inherit; text-decoration: none;">
                    <h4>Options</h4>
                </a>
                <p>The options are part of an interface called the RenderOptions. You can checkout the API for details on each option.</p>
                <a href="#r" id="r" style="color: inherit; text-decoration: none;">
                    <h3>.r</h3>
                </a>
                <p>The <code>.r</code> getter calls the <code>.render()</code> method without any templates or options.</p>
                <pre><code class="language-javascript">H.div().r; <span class="hljs-comment">// output: &quot;&lt;div&gt;&lt;/div&gt;&quot;</span></code></pre>
                <a href="#tostring" id="tostring" style="color: inherit; text-decoration: none;">
                    <h3>.toString()</h3>
                </a>
                <pre><code class="language-javascript">H.div() + <span class="hljs-string">&quot;&quot;</span>; <span class="hljs-comment">// output: &quot;&lt;div&gt;&lt;/div&gt;&quot;</span>

<span class="hljs-comment">// equivalent to:</span>
H.div().toString();</code></pre>
                <a href="#custom-tagscompositions" id="custom-tagscompositions" style="color: inherit; text-decoration: none;">
                    <h2>Custom Tags/Compositions</h2>
                </a>
                <p>Aych wants to remain flexible which means allowing developers to extend the library. Aych makes this possible through
                the <code>Aych.create()</code> and <code>Aych.compose()</code>.</p>
                <a href="#aychcreate" id="aychcreate" style="color: inherit; text-decoration: none;">
                    <h3>Aych.create()</h3>
                </a>
                <p><code>Aych.create()</code> allows you to define custom HTML tags to be used within H. You create a tag by specifying whether it&#39;s
                nestable or empty and then naming it. These tags can be used just like any other renderable in Aych.</p>
                <pre><code class="language-javascript">Aych.create(<span class="hljs-string">&#x27;custom&#x27;</span>, Aych.ElementType.NESTED);
Aych.create(<span class="hljs-string">&#x27;custom-element&#x27;</span>, Aych.ElementType.EMPTY);

H.custom(<span class="hljs-string">&quot;#id&quot;</span>).r; <span class="hljs-comment">// output: &lt;custom id=&quot;id&quot;&gt;&lt;/custom&gt;</span>
H.customElement().r <span class="hljs-comment">// output: &lt;custom-element&gt;&lt;/custom-element&gt;</span></code></pre>
                <p><strong>Note: The name of the tag should be a valid HTML tag name.</strong></p>
                <a href="#aychcompose" id="aychcompose" style="color: inherit; text-decoration: none;">
                    <h3>Aych.compose()</h3>
                </a>
                <p>In Aych, a composition is a reusable set of HTML elements. A composition is created using the <code>compose</code> method under
                    <code>Aych</code>. The first parameter is the name of the composition while the second parameter is an anonymous function that
                    should return the renderable that represents the composition. The arguments injected into the anonymous function
                will correspond to the arguments used in the composition call.</p>
                <pre><code class="language-javascript">Aych.compose(<span class="hljs-string">&#x27;row&#x27;</span>, <span class="hljs-function">(<span class="hljs-params">title, value</span>) =&gt;</span>
    H.div(<span class="hljs-string">&#x27;.row&#x27;</span>,
        H.div(<span class="hljs-string">&#x27;.col&#x27;</span>,
            H.strong(title),
            H.unescaped(<span class="hljs-string">&#x27;: &#x27;</span> + value)
            <span class="hljs-comment">// If &#x27;value&#x27; is a renderable then the concatination between &#x27;: &#x27; and &#x27;value&#x27; will cause </span>
            <span class="hljs-comment">// &#x27;value&#x27; to automatically render resulting in HTML (see the .toString() section). </span>
            <span class="hljs-comment">// Without unescaped, the parent div would escape these HTML characters giving unexpected results.</span>
        )
    )
);

H.row(<span class="hljs-string">&quot;Name&quot;</span>, H.span(<span class="hljs-string">&quot;John Doe&quot;</span>)).r;</code></pre>
                <p>Produces:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;row&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;col&quot;</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">strong</span>&gt;</span>Name<span class="hljs-tag">&lt;/<span class="hljs-name">strong</span>&gt;</span>: <span class="hljs-tag">&lt;<span class="hljs-name">span</span>&gt;</span>John Doe<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></code></pre>
                <a href="#aychdestroy" id="aychdestroy" style="color: inherit; text-decoration: none;">
                    <h3>Aych.destroy()</h3>
                </a>
                <p>You can remove tags or compositions using the <code>destroy</code> method under Aych.</p>
                <pre><code class="language-javascript">Aych.destroy(<span class="hljs-string">&#x27;div&#x27;</span>);
<span class="hljs-comment">// H.div().r // no longer is valid because it was removed.</span></code></pre>
                <a href="#piper" id="piper" style="color: inherit; text-decoration: none;">
                    <h2>Piper</h2>
                </a>
                <p>Piper is the piping engine for Aych. Piper lives used <code>Aych.Piper</code> and allows you to register, deregister, or update
                    the pipes that you can use inside of string literals during templating. Pipes can take optional arguments which can
                either be a string, number or boolean.</p>
                <a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
                    <h3>Usage</h3>
                </a>
                <p>Pipes are used within string literals to modify the data pass in. </p>
                <pre><code class="language-javascript">H.string(<span class="hljs-string">&quot;{{text|uppercase()}}&quot;</span>).render({ <span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;hello&#x27;</span> });
<span class="hljs-comment">// OR</span>
H.string(<span class="hljs-string">&quot;{{text|uppercase}}&quot;</span>).render({ <span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;hello&#x27;</span> });
<span class="hljs-comment">// output: HELLO</span></code></pre>
                <p>In the above example, the uppercase pipe takes in some text and turns it to uppercase. Using parentheses are optional
                unless you want to specify parameters:</p>
                <pre><code class="language-javascript">H.string(<span class="hljs-string">&quot;{{text|substr(1, 3))}}&quot;</span>).render({ <span class="hljs-attr">text</span>: <span class="hljs-string">&#x27;hello&#x27;</span> });
<span class="hljs-comment">// output: ell</span></code></pre>
                <p>Piper does not require arguments even if you create a pipe with arguments. If you want these arguments to be required,
                you will have to manually error handle the undefined arguments. See the <code>addLetter</code> example below.</p>
                <a href="#register--deregister-pipe" id="register--deregister-pipe" style="color: inherit; text-decoration: none;">
                    <h3>Register / Deregister Pipe</h3>
                </a>
                <p>The way that you register a pipe is like this:</p>
                <pre><code class="language-javascript">Aych.Piper.register(<span class="hljs-string">&#x27;PIPE NAME HERE&#x27;</span>, <span class="hljs-function">(<span class="hljs-params">str, optionalArg1, optionalArg2, ...</span>) =&gt;</span> {
    <span class="hljs-comment">// Do something to str here.</span>
    <span class="hljs-keyword">return</span> str;
});</code></pre>
                <p>You can deregister a pipe using <code>Aych.Piper.deregister(&#39;PIPE NAME HERE&#39;)</code>.</p>
                <p>Alternatively, if you simply want to update an existing pipe, you can use the update method. The signature used is
                slightly modified. The previous pipe function will be given to you as the first argument:</p>
                <pre><code class="language-javascript">Aych.Piper.update(<span class="hljs-string">&#x27;PIPE NAME HERE&#x27;</span>, <span class="hljs-function">(<span class="hljs-params">original, str, optionalArg1, optionalArg2, ...</span>) =&gt;</span> {
    <span class="hljs-comment">// Do something to str here.</span>
    <span class="hljs-keyword">return</span> original(str);
});</code></pre>
                <p>An example with all these concepts:</p>
                <pre><code class="language-javascript">Aych.Piper.register(<span class="hljs-string">&#x27;addLetter&#x27;</span>, <span class="hljs-function">(<span class="hljs-params">str, letter</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span> (letter === <span class="hljs-literal">undefined</span>) letter = <span class="hljs-string">&#x27;a&#x27;</span>;
    <span class="hljs-keyword">return</span> str + letter;
});

H.div(<span class="hljs-string">&#x27;{{text|addLetter(!)}}&#x27;</span>).render({<span class="hljs-attr">text</span>: <span class="hljs-string">&quot;Hello&quot;</span>}); <span class="hljs-comment">// output: &quot;Hello!&quot;</span>
H.div(<span class="hljs-string">&#x27;{{text|addLetter}}&#x27;</span>).render({<span class="hljs-attr">text</span>: <span class="hljs-string">&quot;Hello&quot;</span>}); <span class="hljs-comment">// output: &quot;Helloa&quot; (missing argument uses letter &#x27;a&#x27;)</span>

Aych.Piper.update(<span class="hljs-string">&#x27;addLetter&#x27;</span>, <span class="hljs-function">(<span class="hljs-params">original, str, letter</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span> (letter === <span class="hljs-literal">undefined</span>) letter = <span class="hljs-string">&#x27;a&#x27;</span>;
    <span class="hljs-keyword">return</span> letter + original(str, letter);
});

H.div(<span class="hljs-string">&#x27;{{text|addLetter(!)}}&#x27;</span>).render({<span class="hljs-attr">text</span>: <span class="hljs-string">&quot;Hello&quot;</span>}); <span class="hljs-comment">// output: &quot;!Hello!&quot;</span>

Aych.Piper.deregister(<span class="hljs-string">&#x27;addLetter&#x27;</span>);
<span class="hljs-comment">// Using addLetter as a pipe after this point will throw an error.</span></code></pre>
                <a href="#statements" id="statements" style="color: inherit; text-decoration: none;">
                    <h2>Statements</h2>
                </a>
                <p>Statements are special renderable&#39;s that modify the way other renderables get rendered. Statements are the power that
                    Aych provides to write shorter code. Statements are all under the <code>H</code> variable and are all preceeded by a dollar sign
                    (<code>$</code>). Again, statements are renderable so they have  <code>.render()</code> and <code>.r</code> methods and thus can be used as children just
                like regular tags.</p>
                <a href="#-scope" id="-scope" style="color: inherit; text-decoration: none;">
                    <h3>$ (scope)</h3>
                </a>
                <p>The <code>$</code> statement is called the scope statement. This statement is used to improved the readability of your Aych code
                    by scoping H within an anonymous function and restricting new pipes, new tags, and new creations within this anonymous
                function. </p>
                <pre><code class="language-javascript">H.$((H) =&gt; {
   <span class="hljs-comment">// Use H here. Any new pipes, tags, or creations that are added will be removed </span>
   <span class="hljs-comment">// after this anonymous function runs.</span>
   <span class="hljs-keyword">return</span> H.div();
}); <span class="hljs-comment">// output: &lt;div&gt;&lt;/div&gt;</span></code></pre>
                <p>You may notice that the anonymous function injects <code>H</code> as the first parameter. While this is not required, it is
                    recommended to use destructuring to pull out the necessary tags or statements. You will also see that with this
                    statement you <code>return</code> the final element construction. <code>.r</code> is optional here as the scope statement will call it
                automatically. However, if you want to include templates you need to explicitly call &#39;.render()&#39;</p>
                <p>Full example:</p>
                <pre><code class="language-javascript">H.$(({ $switch, $<span class="hljs-keyword">case</span>, input, html, body, title, head }) =&gt; {
    <span class="hljs-keyword">const</span> type = <span class="hljs-string">&#x27;password&#x27;</span>;
    <span class="hljs-keyword">return</span> html(
        head(
            title(<span class="hljs-string">&#x27;Some Title&#x27;</span>),
        ),
        body(
            $switch(type,
                $<span class="hljs-keyword">case</span>(<span class="hljs-string">&#x27;text&#x27;</span>, input({ <span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;text&#x27;</span> })),
                $<span class="hljs-keyword">case</span>(<span class="hljs-string">&#x27;password&#x27;</span>, input({ <span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;password&#x27;</span> })),
                $<span class="hljs-keyword">case</span>(<span class="hljs-string">&#x27;hidden&#x27;</span>, input({ <span class="hljs-attr">type</span>: <span class="hljs-string">&#x27;hidden&#x27;</span> }))
            ),
        )
    )
});</code></pre>
                <p>Produces:</p>
                <pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
       <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Some Title<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span> 
    <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;password&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span></code></pre>
                <p>Again, note that no explicit render method is required. </p>
                <a href="#if" id="if" style="color: inherit; text-decoration: none;">
                    <h3>$if</h3>
                </a>
                <p>Rendering HTML conditionally can prove to be extremely useful. The <code>$if</code> statement accomplishes just that.</p>
                <pre><code class="language-javascript">H.$if(<span class="hljs-literal">true</span>, H.div(), H.span()).r; <span class="hljs-comment">// output: &lt;div&gt;&lt;/div&gt;</span>
H.$if(<span class="hljs-literal">false</span>, H.div(), H.span()).r; <span class="hljs-comment">// output: &lt;span&gt;&lt;/span&gt;</span>
H.$if(<span class="hljs-literal">false</span>, H.div()).else(H.span()).r; <span class="hljs-comment">// output: &lt;span&gt;&lt;/span&gt;</span>

<span class="hljs-comment">// Use else if:</span>
H.$if(<span class="hljs-literal">false</span>, H.div()).elif(<span class="hljs-literal">false</span>, H.span()).elif(<span class="hljs-literal">true</span>, H.strong()).r; <span class="hljs-comment">// output: &lt;strong&gt;&lt;/strong&gt;</span>

<span class="hljs-comment">// Nested if:</span>
H.$if(<span class="hljs-literal">true</span>, 
    H.$if(<span class="hljs-literal">false</span>,
        H.div(),
        H.span()
    ),
    H.strong()
).r <span class="hljs-comment">// output: &lt;span&gt;&lt;/span&gt;</span></code></pre>
                <a href="#each" id="each" style="color: inherit; text-decoration: none;">
                    <h3>$each</h3>
                </a>
                <p>The <code>$each</code> statement renders a renderable for each item in a list. The <code>eachIn</code> is similar but instead works with
                a key,value paired object.</p>
                <p>The each statement is very powerful because it allows multiplying HTML elements based on a list.</p>
                <pre><code class="language-javascript">H.$each([<span class="hljs-string">&#x27;John&#x27;</span>, <span class="hljs-string">&#x27;Jennifer&#x27;</span>, <span class="hljs-string">&#x27;Samantha&#x27;</span>], H.div(<span class="hljs-string">&quot;{{item}} @ {{i}}&quot;</span>)).r;
<span class="hljs-comment">// output: &lt;div&gt;John @ 0&lt;/div&gt;&lt;div&gt;Jennifer @ 1&lt;/div&gt;&lt;div&gt;Samantha @ 0&lt;/div&gt;</span></code></pre>
                <p>As you can see, the each statement injects two special templating tags called <code>item</code> and <code>i</code> where
                <code>item</code> refers to the element in the array and <code>i</code> refers to the index. You can change these names:</p>
                <pre><code class="language-javascript">H.$each([<span class="hljs-string">&#x27;John&#x27;</span>, <span class="hljs-string">&#x27;Jennifer&#x27;</span>, <span class="hljs-string">&#x27;Samantha&#x27;</span>], H.div(<span class="hljs-string">&quot;{{element}} @ {{index}}&quot;</span>), <span class="hljs-string">&#x27;index&#x27;</span>, <span class="hljs-string">&#x27;element&#x27;</span>).r;
<span class="hljs-comment">// OR</span>
H.$each([<span class="hljs-string">&#x27;John&#x27;</span>, <span class="hljs-string">&#x27;Jennifer&#x27;</span>, <span class="hljs-string">&#x27;Samantha&#x27;</span>], H.div(<span class="hljs-string">&quot;{{element}} @ {{index}}&quot;</span>)).setIndexName(<span class="hljs-string">&#x27;index&#x27;</span>).setIndexName(<span class="hljs-string">&#x27;element&#x27;</span>).r;
<span class="hljs-comment">// output: &lt;div&gt;John @ 0&lt;/div&gt;&lt;div&gt;Jennifer @ 1&lt;/div&gt;&lt;div&gt;Samantha @ 0&lt;/div&gt;</span></code></pre>
                <p>If you need more flexibility, you can use an anonymous function that returns a renderable instead of using the
                renderable directly:</p>
                <pre><code class="language-javascript">H.$each([<span class="hljs-string">&#x27;John&#x27;</span>, <span class="hljs-string">&#x27;Jennifer&#x27;</span>, <span class="hljs-string">&#x27;Samantha&#x27;</span>], <span class="hljs-function">(<span class="hljs-params">item, index, arr</span>) =&gt;</span> H.div(item + <span class="hljs-string">&quot; @ {{index}}&quot;</span>)).r;
<span class="hljs-comment">// output: &lt;div&gt;John @ 0&lt;/div&gt;&lt;div&gt;Jennifer @ 1&lt;/div&gt;&lt;div&gt;Samantha @ 0&lt;/div&gt;</span></code></pre>
                <p>Take note that you can still use templates in this returned renderable. In fact, <code>item</code> and <code>index</code> are available,
                    though including both in the example is a bit redundant. The goal was to show you the signature of this anonymous
                function and what it injects.</p>
                <p><strong>What happens if the list is empty?</strong>
                In case you want to have a special element used if the list is empty, you can chain on the <code>.empty()</code> method:</p>
                <pre><code class="language-javascript">H.$each([], H.div(<span class="hljs-string">&quot;{{item}} @ {{i}}&quot;</span>)).empty(H.span(<span class="hljs-string">&quot;List empty!&quot;</span>)).r;
<span class="hljs-comment">// output: &lt;span&gt;List empty!&lt;/span&gt;</span></code></pre>
                <a href="#eachin" id="eachin" style="color: inherit; text-decoration: none;">
                    <h3>$eachIn</h3>
                </a>
                <p>The <code>$eachIn</code> statement works similar to each in all aspects expect for the input of data. The data in an each in
                statement is an key,value object.</p>
                <pre><code class="language-javascript">H.$eachIn({
    <span class="hljs-string">&quot;date&quot;</span>: <span class="hljs-string">&quot;08/08/2020&quot;</span>,  
    <span class="hljs-string">&quot;age&quot;</span>: <span class="hljs-number">19</span>,
}, H.div(<span class="hljs-string">&quot;{{item[0]}}:{{item[1]}} @ {{i}}&quot;</span>)).r;

<span class="hljs-comment">//OR</span>
H.$eachIn({
    <span class="hljs-string">&quot;date&quot;</span>: <span class="hljs-string">&quot;08/08/2020&quot;</span>,  
    <span class="hljs-string">&quot;age&quot;</span>: <span class="hljs-number">19</span>,
}, <span class="hljs-function">(<span class="hljs-params">[key, value], index</span>) =&gt;</span> H.div(key + <span class="hljs-string">&quot;:&quot;</span> + value + <span class="hljs-string">&quot; @ &quot;</span> + index)).r;

<span class="hljs-comment">// output: &lt;div&gt;date:08/08/2020 @ 0&lt;/div&gt;&lt;div&gt;age:19 @ 1&lt;/div&gt;</span></code></pre>
                <p>Just like with the <code>$each</code> statement, you can call <code>setIndexName</code>, <code>setItemName</code>, and <code>empty</code>.</p>
                <a href="#repeat" id="repeat" style="color: inherit; text-decoration: none;">
                    <h3>$repeat</h3>
                </a>
                <p>The <code>$repeat</code> statement will copy an element some number of times.</p>
                <pre><code class="language-javascript">H.$repeat(<span class="hljs-number">3</span>, H.div(<span class="hljs-string">&quot;I&#x27;m div number: {{i}}&quot;</span>)).r;
<span class="hljs-comment">// OR:</span>
H.$repeat(<span class="hljs-number">3</span>, <span class="hljs-function">(<span class="hljs-params">i</span>) =&gt;</span> {
    <span class="hljs-keyword">return</span> H.div(<span class="hljs-string">&quot;I&#x27;m div number: &quot;</span> + i);
}).r;

<span class="hljs-comment">// output: &lt;div&gt;I&#x27;m div number: 0&lt;/div&gt;&lt;div&gt;I&#x27;m div number: 1&lt;/div&gt;&lt;div&gt;I&#x27;m div number: 2&lt;/div&gt;</span></code></pre>
                <a href="#group" id="group" style="color: inherit; text-decoration: none;">
                    <h3>$group</h3>
                </a>
                <p>The <code>$group</code> statement groups elements together for rendering.</p>
                <p>By using a group statement, we are able to logically group a set of renderable elements. In the example below, we
                compare how to use a group statement.</p>
                <pre><code class="language-javascript"><span class="hljs-keyword">const</span> type = <span class="hljs-string">&#x27;password&#x27;</span>;
$group(
    H.div({ <span class="hljs-attr">id</span>: [type !== <span class="hljs-string">&#x27;password&#x27;</span>, <span class="hljs-string">&#x27;someid&#x27;</span>] }, <span class="hljs-string">&#x27;{{age}}&#x27;</span>),
    H.div({ <span class="hljs-attr">class</span>: [type === <span class="hljs-string">&#x27;password&#x27;</span>, <span class="hljs-string">&#x27;+password&#x27;</span>, <span class="hljs-string">&#x27;+none&#x27;</span>]}, <span class="hljs-string">&#x27;{{name}}&#x27;</span>),
    H.div(<span class="hljs-string">&quot;{{school}}&quot;</span>)
).render({ <span class="hljs-attr">age</span>: <span class="hljs-number">19</span>, <span class="hljs-attr">name</span>: <span class="hljs-string">&#x27;John&#x27;</span>, <span class="hljs-attr">school</span>: <span class="hljs-string">&#x27;UGA&#x27;</span> });
<span class="hljs-comment">// output: &lt;div&gt;19&lt;/div&gt;&lt;div class=&quot;password&quot;&gt;John&gt;&lt;/div&gt;&lt;div&gt;UGA&lt;/div&gt;</span>

<span class="hljs-comment">// Equivalent to:</span>
<span class="hljs-keyword">const</span> type = <span class="hljs-string">&#x27;password&#x27;</span>;
H.div({ <span class="hljs-attr">id</span>: [type !== <span class="hljs-string">&#x27;password&#x27;</span>, <span class="hljs-string">&#x27;someid&#x27;</span>] }, <span class="hljs-string">&#x27;{{age}}&#x27;</span>).render({ <span class="hljs-attr">age</span>:<span class="hljs-number">19</span> }) +
H.div({ <span class="hljs-attr">class</span>: [type === <span class="hljs-string">&#x27;password&#x27;</span>, <span class="hljs-string">&#x27;+password&#x27;</span>, <span class="hljs-string">&#x27;+none&#x27;</span>]}, <span class="hljs-string">&#x27;{{name}}&#x27;</span>).render({ <span class="hljs-attr">name</span>:<span class="hljs-string">&#x27;John&#x27;</span> }) +
H.div(<span class="hljs-string">&quot;{{school}}&quot;</span>).render({ <span class="hljs-attr">school</span>: <span class="hljs-string">&#x27;UGA&#x27;</span> });</code></pre>
                <p>As you can see, in the alternative, when not using a group statement, you have repeated render calls and you have to
                concat the strings together.</p>
                <a href="#switch--case" id="switch--case" style="color: inherit; text-decoration: none;">
                    <h3>$switch / $case</h3>
                </a>
                <p>The <code>$switch</code> statement allows you to toggle between a set of elements based on some input. This statement is used with
                the <code>$case</code> statement.</p>
                <pre><code class="language-javascript"><span class="hljs-keyword">const</span> value = <span class="hljs-number">3</span>;
H.$switch(value,
    H.$<span class="hljs-keyword">case</span>(<span class="hljs-number">0</span>, H.div()),
    H.$<span class="hljs-keyword">case</span>(<span class="hljs-number">1</span>, H.span()),
    H.$<span class="hljs-keyword">case</span>(<span class="hljs-number">2</span>, H.strong()),
    H.$<span class="hljs-keyword">case</span>(<span class="hljs-number">3</span>, H.h1()),
).r; <span class="hljs-comment">// output: &lt;h1&gt;&lt;/h1&gt;</span></code></pre>
                <p>Just like switch statements in JavaScript, our <code>$switch</code> statements also support a default in case when none of the
                cases are met:</p>
                <pre><code class="language-javascript"><span class="hljs-keyword">const</span> value = <span class="hljs-string">&quot;dog&quot;</span>;
H.$switch(value,
    H.$<span class="hljs-keyword">case</span>(<span class="hljs-string">&quot;cat&quot;</span>, H.div()),
    H.$<span class="hljs-keyword">case</span>(<span class="hljs-string">&quot;tiger&quot;</span>, H.span()),
    H.$<span class="hljs-keyword">case</span>(<span class="hljs-string">&quot;bear&quot;</span>, H.strong()),
    H.$<span class="hljs-keyword">case</span>(<span class="hljs-string">&quot;mouse&quot;</span>, H.h1()),
).default(H.h2()).r; <span class="hljs-comment">// output: &lt;h2&gt;&lt;/h2&gt;</span></code></pre>
                <a href="#more-examples" id="more-examples" style="color: inherit; text-decoration: none;">
                    <h2>More examples</h2>
                </a>
                <p>The tests/ folder in the github is a great place to explore test cases and uses. You will likely find
                    <code>intergration.ts</code> and <code>h.test.ts</code> the most interesting as they use the library directly. The subfolders
                will contain more internal testing but also serve as valuable example.</p>
            </div>
            <!--{&quot;options&quot;:&quot;typedoc.json&quot;,&quot;tsconfig&quot;:&quot;/Users/shawnholman/Desktop/Aych&quot;,&quot;inputFiles&quot;:[&quot;./src&quot;],&quot;mode&quot;:1,&quot;includeDeclarations&quot;:false,&quot;entryPoint&quot;:&quot;&quot;,&quot;exclude&quot;:[],&quot;externalPattern&quot;:[],&quot;excludeExternals&quot;:true,&quot;excludeNotExported&quot;:true,&quot;excludeNotDocumented&quot;:false,&quot;excludePrivate&quot;:true,&quot;excludeProtected&quot;:false,&quot;ignoreCompilerErrors&quot;:false,&quot;disableSources&quot;:false,&quot;includes&quot;:&quot;&quot;,&quot;media&quot;:&quot;&quot;,&quot;out&quot;:&quot;./docs&quot;,&quot;json&quot;:&quot;&quot;,&quot;theme&quot;:&quot;node_modules/typedoc-neo-theme/bin/default&quot;,&quot;name&quot;:&quot;Aych&quot;,&quot;includeVersion&quot;:false,&quot;excludeTags&quot;:[],&quot;readme&quot;:&quot;DOCUMENTATION.md&quot;,&quot;defaultCategory&quot;:&quot;Other&quot;,&quot;categoryOrder&quot;:[],&quot;categorizeByGroup&quot;:true,&quot;gitRevision&quot;:&quot;&quot;,&quot;gitRemote&quot;:&quot;origin&quot;,&quot;gaID&quot;:&quot;&quot;,&quot;gaSite&quot;:&quot;auto&quot;,&quot;hideGenerator&quot;:false,&quot;toc&quot;:[],&quot;disableOutputCheck&quot;:false,&quot;help&quot;:false,&quot;version&quot;:false,&quot;plugin&quot;:[&quot;typedoc-neo-theme&quot;],&quot;logger&quot;:&quot;console&quot;,&quot;listInvalidSymbolLinks&quot;:false,&quot;outline&quot;:[{&quot;Library&quot;:{&quot;H&quot;:&quot;_h_&quot;,&quot;Aych&quot;:&quot;classes/_core_aych_.aych&quot;},&quot;Core&quot;:{&quot;Piper&quot;:&quot;classes/_core_piper_.piper&quot;,&quot;Renderable&quot;:&quot;classes/_core_renderable_.renderable&quot;,&quot;StringLiteral&quot;:&quot;classes/_core_stringliteral_.stringliteral&quot;},&quot;Elements&quot;:{&quot;Element&quot;:&quot;classes/_elements_element_.element&quot;,&quot;EmptyElement&quot;:&quot;classes/_elements_emptyelement_.emptyelement&quot;,&quot;NestableElement&quot;:&quot;classes/_elements_nestableelement_.nestableelement&quot;},&quot;Interfaces&quot;:{&quot;Attributes&quot;:&quot;interfaces/_interfaces_attributes_.attributes&quot;,&quot;RenderOptions&quot;:&quot;interfaces/_interfaces_render_options_.renderoptions&quot;,&quot;SimpleObject&quot;:&quot;interfaces/_interfaces_simple_object_.simpleobject&quot;},&quot;Structural&quot;:{&quot;Each&quot;:&quot;classes/_structural_each_.each&quot;,&quot;If&quot;:&quot;classes/_structural_if_.if&quot;,&quot;Switch&quot;:&quot;classes/_structural_switch_.switch&quot;,&quot;Group&quot;:&quot;classes/_structural_group_.group&quot;}}]}-->
        </div>
        <div class="col-2 col-menu secondary-menu">
            <nav class="tsd-navigation secondary menu-sticky">
                <ul class="before-current">
                </ul>
            </nav>
        </div>
    </div>
</div>
<footer class="with-border-bottom">
</footer>
<div class="container tsd-generator">
    <p>Generated using <a href="http://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="assets/js/search.js"><' + '/script>');</script>
</body>
</html>