New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

brown

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brown

Ultra-extendable Mustache-ish template engine on steroids in 620 gzipped kilobytes, need nothing more!

  • 1.1.23
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-46.15%
Maintainers
1
Weekly downloads
 
Created
Source

ϐrown

Jade-ish + Mustache-ish template engine on steroids in 846 gzipped kilobytes

Usage

$ npm install brown

or in the browser:

<script type='text/javascript' src='brown.min.js'></script>

Simple

brown.render( "hello {{foo.bar}}", { 
  foo: {
    bar: "world" 
  } 
});

outputs:

hello world

Functions

Create a fullfledged template engine by adding functions:

brown.encode = function(key,type) {
  var html = this[key] || '';
  return  type == "html" ?
          String(html).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/</g, '&lt;').replace(/>/g, '&gt;') :
          html
};

brown.render( 'a href="{{href}}" onclick="{{encode:label:html}}"': "{{label}}", {
  href="/", 
  label:"my \"label\""} 
});

outputs:

<div>
  <ul>
    <li>
      <a href="/" onclick="my &quot;label&quot;">my "label"</a>
    </li>
  </ul>
</div>

If / Else / Looping

Need more? See brown-ext-basic for if/foreach/filter/loop-functionality.

Generate xml/html from jsonportable JADE

ϐrown can be monkeypatched, to automatically produce xml-trees from json (like JADE), see this coffeescript example:

json = 
  ul: 
    li: 'a href="{{foo}}": "Click me"

brown.render json,{ foo: "/" }

outputs:

<ul>
  <li>
    <a href="/">Click me </a>
  </li>
</ul>

How? Simple, by just monkeypatching ϐrown with json-dsl. See coffeescript / JS examples.

Commandline util

Use as a commandline generator (install using npm install -g ) :

  $ brown
    Usage: brown <string|file> [jsonstring|jsonfile]

  examples:
          $ brown 'foo {{foo}}' '{"foo":"world"}'
          $ brown foo.html data.json

Goals / Philosophy

  • lightweight and extendable
  • mustache without the noise and weight (mustache is a whopping 97k and pretty slow)

With ϐrown as a fundament you can literally do anything.

Extentions & Dependents

Roadmap

  • stability and peace

Keywords

FAQs

Package last updated on 07 Dec 2015

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