Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

templejs

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

templejs

A reactive Mustache view framework.

  • 0.5.12
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30
decreased by-25%
Maintainers
2
Weekly downloads
 
Created
Source

Temple

A JavaScript view framework.

  • Reactive - Powered by Trackr, Temple automatically updates the DOM as data changes.
  • Template Driven - Use a Mustache-HTML hybrid syntax to quickly generate UI scaffolding.
  • Modular & Extensible - All views are encapsulated, reusable components.
  • Data Neutral - Temple can be easily integrated with existing frameworks and platforms.

Example

Here is a basic example of using Temple. This just uses a simple variable, but Temple has support for most of the major Mustache features.

// create a view instance from a template and data
var tpl = Temple.render("<h1>Hello {{ name }}</h1>", { name: "World" });

// render and append to the document body
tpl.paint("body");

// later, change the value and watch it auto-update the DOM
tpl.data.name = "John";

Listening for DOM events is really easy in Temple. Enable the plugin and then add an on-<event> attribute to any element.

// create a view instance from just a template
var tpl = Temple.render("<a href='#' on-click='alert'>Click Me</a>")

// enable the DOM events plugin
.use("actions")

// add the special alert action
.addAction("alert", function(e) {
    e.original.preventDefault();
    alert("You clicked me!");
})

// render and append to the document body
.paint("body");

Temple even lets you turn your views into reusable components.

// a reusable View class
var Hello = Temple.extend({
    template: "Hello {{ name }}"
});

// render a new template that uses the view as a partial
var tpl = Temple.render("<h1>{{> hello }}</h1>", { name: "John" })
.setPartial("hello", Hello)
.paint("body");

// views can also be rendered directly
var tpl2 = new Hello({ name: "World" }).paint("body");

Keywords

FAQs

Package last updated on 08 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc