Socket
Socket
Sign inDemoInstall

beard

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    beard

More than a mustache.


Version published
Maintainers
1
Created

Readme

Source

Beard

More than a mustache.

Released under a MIT license.

Features

  • Clean syntax

Usage

Install

npm install beard

API

const Beard = require('beard');
const engine = new Beard(cache, lookup);
engine.render(template, locals);

Beard Constructor Arguments

cache - (object) An object literal containing your templates.

lookup - (function) A function that accepts the path value and can modify the path value before Beard looks up your template from the cache. E.g., (path) => '/absolute/cached/path/${path}'.

Render Arguments

template - (string) A string to be parsed and populated by the view object.

locals - (object) An object of data and/or methods which will populate the template string.

Example

const templates = {
	'example': "{{noun}} get {{makeUpperCase('stinky')}}."
};

const locals = {
	noun: "Beards",
	makeUpperCase: function(str){
		return str.toUpperCase();
	}
};

const Beard = require('beard');
const engine = new Beard(templates);
const result = engine.render("{{include 'example'}}", locals);
console.log(result); // returns 'Beards get STINKY.'

More docs to come...

  • cache
  • optional cache lookup function

Thanks to

  • keeto (Mark Obcena) for the parser/compiler
  • shinetech (Danny Brain) for syntax ideas
  • joeosburn (Joe Osburn) for the updated compiler, cached compiled functions, tests, and benchmarks

Keywords

FAQs

Last updated on 16 Jan 2018

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc