npm

Need private packages and team management tools?Check out npm Orgs. »

octet

3.0.0 • Public • Published

octet npmjs.com The MIT License

1kb template engine for the browser and nodejs. Support helpers, partials and more.
Used in AbsurdJS Apps.

code climate standard code style travis build status coverage status dependency status

Install

npm i octet --save

Features

  • minimal, yet simple
    • 845 bytes - browserified, gzipped and minified
    • 1676 bytes - browserified and minified
  • zero dependencies
  • works on every browser, should even works on IE6 or at least IE8
  • works on the server with just require('octet')
  • plays well with Browserify and BrowserifyCDN
  • support helpers and partials
  • available on CDNs - BrowserifyCDN and RawGit CDN

Use it

Usage

For more use-cases see the tests.
You can use any "helpers" lib, for example utils.

var octet = require('octet')
var utils = require('utils')
 
octet.render('foo <%this.uppercase("bar")%> baz', utils._)
//=> 'foo BAR baz'

octet

Acts like .render by default. Renders given str with locals.

  • str {String} template to populate with locals
  • locals {Object} locals object
  • returns {String} rendered string

Example

octet('foo <%this.bar%> baz <%this.quux%>', {bar: 'bar', quux: 'QUUX'})
//=> 'foo bar baz QUUX'

.render

Renders given str with locals.

  • str {String} template to populate with locals
  • locals {Object} locals object
  • returns {String} rendered string

Example

octet.render('Hello <%this.place%> and <%this.user.name%>!', {
  place: 'world',
  user: {
    name: 'Charlike'
  }
})
//=> 'Hello world and Charlike!'

.compile

Compiles given string and returns function which accepts locals object.

  • str {String} template to populate
  • returns {Function} which accepts locals objects

Example

var fn = octet.compile('Hello <%this.place%> and <%this.user.name%>!')
fn({place: 'world', user: {name: 'Charlike'}})
//=> 'Hello world and Charlike!'

Related

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github

install

npm i octet

Downloadsweekly downloads

27

version

3.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability