# gza **Repository Path**: mirrors_mikeal/gza ## Basic Information - **Project Name**: gza - **Description**: Functional custom HTML elements. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2025-09-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GZA Declarative custom HTML elements

```javascript const gza = require('gza') gza` ${ settings => settings.test } ` ``` ```html pass test-prop ``` See also [markdown-element](https://github.com/mikeal/markdown-element) which is implemented with `gza` # Features ## Initialization Functions Any function defined before your element definition is an initialization function. It takes a single argument, an instance of the new element. Only after all intialization functions have finished, including async functions, will the render function be called. Initialization functions are only ever called once per element instance. ```javascript gza` ${async element => { let resp = await fetch('flowers.jpg') let blob = await resp.blob() element.src = URL.createObjectURL(blob) }} ` ``` ## Templatized Rendering All content and functions defined inside your element definition are used for templatized rendering. The content and function results are used to display content in the `` element. Every time an element attribute or element property changes that was previously defined by the defaults, the entire element template will be run again in order to re-render. Every time the contents of the element changes it will also call the template functions in order to re-render. ```javascript gza`

${settings => settings.one}

${settings => settings.two}

${settings => settings.three}

` ``` ```html

1

2

3

one

two

three

``` ## ShadowDOM Any content defined **below** your element definition will be attached to the shadowDOM. If you do not create a `slot` for `"render"` then the rendered content will have nowhere to display. You can also include template functions to dynamically change the shadowDOM content and styling when properties and values change. ```javascript const nowhitespace = str => str.replace(/ /g, '') gza` ${(settings, innerHTML) => nowhitespace(innerHTML)}

${(settings, innerHTML) => nowhitespace(innerHTML)}

` ``` ```html This is a test.

Thisisatest.

Thisisatest.
``` ## Kitchen Sink Here's an example of every feature currently implemented. ```javascript const gza = require('gza') gza` ${element => { /* initialization function */ element.i += 1 }} ${async element => { /* supports async functions */ element.i += 1 }}
${settings => settings.i}
${async settings => settings.test}
${(settings, innerHTML) => innerHTML}

Test

` ``` ```html TestContent

Test

2
test
TestContent
TestContent ``` # Why is it called GZA? Cause GZA the **genius!**