# temple-events

> Adds DOM event actions to Temple's Mustache view.

Latest version **1.1.6** (published 2014-07-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install temple-events
pnpm add temple-events
yarn add temple-events
bun add temple-events
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.6 |
| Published | 2014-07-02 |
| First published | 2014-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Beneath the Ink |
| Maintainers | mrgalaxy, beneaththeink |
| Keywords | temple, events |

## Links

- npm: https://www.npmjs.com/package/temple-events
- Repository: https://github.com/BeneathTheInk/temple-events
- Issues: https://github.com/BeneathTheInk/temple-events/issues
- npm.io page: https://npm.io/package/temple-events

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.1.6 (latest) — 2014-07-02
- 1.1.5 — 2014-06-27
- 1.1.4 — 2014-06-25
- 1.1.3 — 2014-06-22
- 1.1.2 — 2014-06-13
- 1.1.1 — 2014-06-13
- 1.1.0 — 2014-06-13
- 1.0.6 — 2014-06-12
- 1.0.5 — 2014-06-09
- 1.0.3 — 2014-05-28
- 1.0.2 — 2014-05-18
- 1.0.1 — 2014-05-18
- 1.0.0 — 2014-05-17

## README

# Temple Events

Adds DOM event actions to [Temple](https://github.com/BeneathTheInk/Temple)'s Mustache view.

## Install

Download the latest version `dist/` folder and use via a script tag. The variable `Events` will be attached to `Temple`.

```html
<script type="text/javascript" src="temple.js"></script>
<script type="text/javascript" src="temple.events.js"></script>
```

If using Browserify or Node.js, you can install via NPM and use via `require("temple-events")`.

	$ npm install temple-events

## Usage

Add to an instance of a Mustache view (`Temple.Mustache`) with `view.use(Temple.Events)`. This will set up decorators that look for element attributes in the form of `on-[event]`. The attribute value will be parsed for action names to be fired on the view. The first argument passed will be an `Action` object. It's also possible to pass along other values to actions. These will be added as arguments to the triggered action.

```html
<a href="#" on-click="myEvent, 'Hello', {{ noun }}">Click Me</a>
```

```javascript
// a new mustache template
new Temple.Mustache(template, { noun: "World" })

// init the plugin
.use(Temple.Events)

.addAction("myEvent", function(action, str, noun) {
	action.original.preventDefault();
	alert(str + " " + noun); // "Hello World"
});
```

`Action` objects have the following properties:

* `bubbles`: A boolean indicating if the action should continue bubbling through remaining actions, including parent components.
* `stopPropagation()`: A method that sets `bubbles` to false.
* `original`: The original, native DOM event
* `node`: The element the action is attached too
* `context`: The mustache context (`Temple.Mustache.Context`) the element node exists within. Sometimes the original `view`, sometimes not.

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