An open API service indexing awesome lists of open source software.

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

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');
```