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 modern JavaScript view framework.

  • 0.3.4
  • Source
  • npm
  • Socket score

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

Temple

A modern JavaScript view framework.

  • Modular & Extensible - Views are encapsulated, reusable components, making testing and separation of concerns easy.
  • Data Neutral - Temple is focused purely on the View aspect of web applications and can be easily integrated with existing frameworks and platforms.
  • Lightweight - Temple has no external dependencies and weighs in at just under 30KB minified.
  • Reactive - Keep the interface up-to-date flexibly with auto-running computations powered by Meteor's dependency package.

Note: This library is under active development. Use at your own risk!

Install

Download the latest version from our release page and use via a script tag. The variable Temple will be attached to window.

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

If using Browserify or Node.js, you can install via NPM and use via require("templejs").

$ npm install templejs

Example

// A simple clock component
var Clock = Temple.Text.extend({
	// on init, set the local text value to the current time
	constructor: function() {
		Temple.Text.call(this, Clock.getTime());
	},

	// start an interval on mount that will continiously update the time
	beforeMount: function(comp) {
		this.interval = setInterval(this.invalidate.bind(this), 500);
	},

	// when the view is unmounted, clear the interval
	onStop: function() {
		clearInterval(this.interval);
		delete this.interval;
	},

	// updates the value of the text binding to the current time
	render: function() {
		this.setValue(Clock.getTime());
	}
}, {
	// a static method that returns the current time as a string
	getTime: function() {
		var date = new Date;

		return [
			date.getHours(),
			date.getMinutes(),
			date.getSeconds()
		].map(function(digit) {
			return (digit < 10 ? "0" : "") + digit;
		}).join(":");
	}
});

// render a new instance of clock in the body element
new Clock().paint("body").mount();

Keywords

FAQs

Package last updated on 24 Sep 2014

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