https://github.com/benstigsen/template.js
easy javascript and html templating
https://github.com/benstigsen/template.js
javascript template templating
Last synced: 9 months ago
JSON representation
easy javascript and html templating
- Host: GitHub
- URL: https://github.com/benstigsen/template.js
- Owner: benstigsen
- Created: 2025-04-04T19:04:04.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-04-04T19:11:17.000Z (9 months ago)
- Last Synced: 2025-04-04T20:23:54.951Z (9 months ago)
- Topics: javascript, template, templating
- Language: JavaScript
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# template.js
simple and minimal templating in javascript.
**methods:**
- `include(path, data = {})` includes the template from `path`, optionally with variables accessible with `data.VARNAME`
- `text(js)` renders the javascript result in the current script element
## example
**index.html**
```html
include("header.html", { title: "Hello World!", date: "2025-04-23" })
```
**header.html**
```html
text(data.title)
text(data.date)
```
final output:
```html
Hello World!
2025-04-23
```
_**note**: it's possible to use the `` tag instead of `` because why not._
## installation/usage
- download/clone and import with `<script src="template.js">`
- or use a cdn like ``
## questions
### what if i want to include css?
use the standard css `@import` rule:
```html
@import url('style.css');
```