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

beard

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beard

More than a mustache.

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
46
decreased by-19.3%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 16 Jan 2018

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