A Simple JavaScript library for embedding Logic inside HTML
GammmJS, authored by Angelo S. Octavio, bridges the gap between static HTML and dynamic JavaScript. It allows you to write loops, conditionals, and variables directly inside your HTML using a unique line-based parsing engine.
To use GammmJS, you must initialize the GammmJS object and then manually load it using the GammmJSDom controller.
const myApp = new GammmJS({
template: document.getElementById('my-template').innerHTML,
data: { name: 'User' },
events: {
greet: function(el, ev) { alert('Hello!'); }
}
});
// Implementation
GammmJSDom.load(document.getElementById('target'), myApp);
Because GammmJS uses a line-by-line parsing engine, you must follow these rules to avoid eval() errors:
<#gammmjs block.
") in your attributes or logic. Always use single-quotes (').
{{' '}}.
You can mix JavaScript and HTML tags seamlessly. You do not need to re-open tags for nested logic like loops inside an else statement.
<#gammmjs
if (this.data.items.length === 0) {
<p>
{{'Empty List'}}
</p>
} else {
<ul>
for(let i=0; i < this.data.items.length; i++) {
<li>
{{this.data.items[i]}}
</li>
}
</ul>
}
#>
Standard <table> tags are often destroyed by browser auto-formatting when logic is injected. Use the gammm- prefix to ensure layout stability.
| Gammm Tag | Standard Tag |
|---|---|
<gammm-table> | <table> |
<gammm-tr> | <tr> |
<gammm-td> | <td> |
template: String containing your UI and logic.data: The state object. Use this.state() to refresh the UI after changes.events: Object containing handler functions.this.state(): Re-renders the entire component.GammmJSDom.load(el, instance): Mounts the component.").gammm-table tags.