Comparing version 1.1.23 to 1.1.24
@@ -7,6 +7,8 @@ // Generated by CoffeeScript 1.9.3 | ||
this.safe_eval = function(str, data) { | ||
var FOO, result; | ||
var FOO, evalstr, result; | ||
str = str.split(':')[0]; | ||
result = ""; | ||
try { | ||
result = new Function('return ( arguments[0]["' + str + '"] )')(data); | ||
evalstr = (!str.match(/\./) ? '["' + str + '"]' : '.' + str); | ||
result = new Function('return ( arguments[0]' + evalstr + ' )')(data); | ||
} catch (_error) { | ||
@@ -13,0 +15,0 @@ FOO = _error; |
{ | ||
"name": "brown", | ||
"version": "1.1.23", | ||
"version": "1.1.24", | ||
"description": "Ultra-extendable Mustache-ish template engine on steroids in 620 gzipped kilobytes, need nothing more!", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "coffee test/test.coffee", | ||
"test": "cake test/test.coffee", | ||
"compile_nocompress": "/bin/bash -c 'browserify -r .:brown > brown.js'", | ||
@@ -9,0 +9,0 @@ "compile": "/bin/bash -c 'browserify -r .:brown | uglifyjs -c > brown.min.js'" |
@@ -1,100 +0,1 @@ | ||
<h1>ϐrown</h1> | ||
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, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>') : | ||
html | ||
}; | ||
brown.render( 'a href="{{href}}" onclick="{{encode:label:html}}"': "{{label}}", { | ||
href="/", | ||
label:"my \"label\""} | ||
}); | ||
outputs: | ||
<div> | ||
<ul> | ||
<li> | ||
<a href="/" onclick="my "label"">my "label"</a> | ||
</li> | ||
</ul> | ||
</div> | ||
## If / Else / Looping | ||
> Need more? See [brown-ext-basic for if/foreach/filter/loop-functionality](https://www.npmjs.com/package/brown-ext-basic). | ||
## 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](https://npmjs.org/package/json-dsl). See [coffeescript](test/jadeish.coffee) / [JS](test/jadeish.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 | ||
* [brown-ext-basic](https://www.npmjs.com/package/brown-ext-basic). | ||
# Roadmap | ||
* stability and peace |
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
25
177
0
2
1
25210
2