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

templates

Package Overview
Dependencies
Maintainers
1
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

templates

Templates is a template prepackager for Express

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
33K
increased by17.15%
Maintainers
1
Weekly downloads
 
Created
Source

Templates

Templates is a jade template prepackager for Express, inspired by Jammit Templates is written in coffeescript by Marcel Miranda.

Source Code

Installation

npm install templates

Usage

Considering your project directory structure is like the following:

app.js
views/
templates/
  notification/
    panel.jade
  profile.jade

Server

var templates = require 'templates'

// Create express app
var app = express.createServer()

app.use(templates({
  
  // src is the directory where jade template files are stored
  src: __dirname + "/templates",
  
  // url is the url the request will respond to
  url: "/templates.js",
  
  // namespace is the javascript object the 
  // templates will be attached to
  namespace: "window.templates"
  
}))

Client

<!-- Add templates script to page -->
<script src="/templates.js"></script>

<!-- Use templates -->
<script>
  
  templates.profile({name: "John", age: 25})
  // Will return a html string based on templates/profile.jade
  
  templates.notification.panel({title: "Error", message: "Could not log in"})
  // Will return a html string based on templates/notification/panel.jade
  
</script>

Production

Templates will look for the process.env.NODE_ENV to see if working on production environment. When running on production, Templates will automatically compress the templates file using uglify-js. When not running on production, Templates will leave jade's compileDebug option to true, which leaves line numbers for debugging purposes.

Copyright © 2012 Marcel Miranda. See LICENSE for further details.

FAQs

Package last updated on 08 Apr 2012

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