Skip to content

tunnckoCore/octet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'

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'

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!'

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.

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github

About

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

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published