# thulium

> A simple, fast, and debuggable templating engine for JS (node + browser)

Latest version **2.0.0** (published 2014-05-15) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install thulium
pnpm add thulium
yarn add thulium
bun add thulium
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2014-05-15 |
| First published | 2013-07-17 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | benbeltran |

## Links

- npm: https://www.npmjs.com/package/thulium
- Repository: https://github.com/freshout-dev/thulium
- Issues: https://github.com/freshout-dev/thulium/issues
- npm.io page: https://npm.io/package/thulium

## Dependencies (2)

- [neon](https://npm.io/package/neon.md) 2.0.x
- [tellurium](https://npm.io/package/tellurium.md) 2.0.x

## Recent versions

- 2.0.0 (latest) — 2014-05-15
- 0.1.4 — 2013-07-30
- 0.1.3 — 2013-07-23
- 0.1.2 — 2013-07-17
- 0.1.1 — 2013-07-17
- 0.1.0 — 2013-07-17

## README

# Thulium (Tm) Templating #

A proper templating engine. With specs and a syntax that isn't crazy (ie. Not
Jade and not EJS).

It depends on [Neon](https://github.com/azendal/neon) for the class
system.


## Usage ##

It's easy to use. If you want it in the browser, just require the files.
If using node:

```
$ npm install thulium
```

From there, it's as easy as:

```
tm = new Thulium({template: "A template string"});
tm.parseSync().renderSync(context);
```

Of course, async methods are available:

```
tm.parse(function () {
  tm.render(context, function (view) {
    console.log(view);
  })
})
```

## Examples ##

### A simple template ###

#### The template ####

```
<h1>Hello, <%= name %></h1>
<% for (var i = 0; i < 10; i++) { %>
<p> You are awesome. </p>
<% } %>
```


#### The context ####

```javascript
{
 name: "Col. Mustard"
}
```

#### The output ####

```html
<h1>Hello, Col. Mustard</h1>

<p> You are awesome. </p>

<p> You are awesome. </p>

<p> You are awesome. </p>

<p> You are awesome. </p>

<p> You are awesome. </p>

<p> You are awesome. </p>

<p> You are awesome. </p>

<p> You are awesome. </p>

<p> You are awesome. </p>

<p> You are awesome. </p>
```

### A printable helper (capture style) ###

#### The template ####

```
<p>
<%= h.reverse(function (){ %>
This is my reversed string.
<% }) %>
</p>
```


#### The context ####

```javascript
{
 h: {
    reverse : function (toCapture) {
      // Let's imagine for a second that templateManager is a reference
      // to a ... um, template manager. That has an instance of the
      // current view. Which is our instance of Tm
      var buffer = templateManager.currentView.renderer.capture(toCapture);
      return buffer.split("").reverse().join("");
    }
 }
}
```

#### The output ####

```html
<p>

.gnirts desrever ym si sihT

</p>
```

### A printable helper (custom style) ###

#### The template ####

```
<p>
<%= h.embolden(function (){ %>
This guy will be bold.
<% }) %>
</p>
```


#### The context ####

```javascript
{
 h: {
    embolden : function (printable) {
      // Let's imagine for a second that templateManager is a reference
      // to a ... um, template manager. That has an instance of the
      // current view. Which is our instance of Tm
      templateManager.currentView.renderer.print("<strong>");

      // here we're printing that stuff inside the block by executing it
      printable();

      return "</strong>";
    }
 }
}
```

#### The output ####

```html
<p>
<strong>
This guy will be bold.
</strong>
</p>
```

---
_Source: https://npm.io/package/thulium · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
