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

tinytim

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinytim - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

3

lib/tinytim.js

@@ -53,3 +53,4 @@ /*!

if (lookup === undef){
throw "tim: '" + path[i] + "' not found in " + tag;
console.error('undef',path[i])
throw new Error("tim: '" + path[i] + "' not found in " + tag);
}

@@ -56,0 +57,0 @@

@@ -5,3 +5,3 @@ {

"homepage": "http://github.com/baryon/node-tinytim",
"version": "0.0.1",
"version": "0.0.2",
"author": "LI Long <lilong@gmail.com>",

@@ -8,0 +8,0 @@ "contributors": [

@@ -16,8 +16,8 @@ #tinytim for node.js [![Build Status](https://secure.travis-ci.org/baryon/node-tinytim.png)](http://travis-ci.org/baryon/node-tinytim)

```javascript
var tinytim = require('../');
var result = tinytim.tim("Hello {{place}}", {place: "world"});
var tim = require('tinytim').tim;
var result = tim("Hello {{place}}", {place: "world"});
console.log(result); // Hello world
```
See test/test.js for example
See [test/test.js](https://github.com/baryon/node-tinytim/blob/master/test/test.js) for example

@@ -141,9 +141,21 @@

To change this, edit the `start` and `end` vars in the code.
*** this will affect all module use tinytim, because node.js cache this package.
```javascript
var tinytim = require('tinytim');
tinytim.start = "<%";
tinytim.end = "%>";
var result = tinytim.tim("Hello <%place%>", {place: "world"});
console.log(result); // Hello world
```
## History
### 0.0.2
* throw an new Error when not found.
### 0.0.1
* Initial port.
* Initial port.

@@ -150,0 +162,0 @@ ## License

var assert = require("assert");
exports["simple"] = function() {
var tinytim = require('../');
var result = tinytim.tim("Hello {{place}}", {place: "world"});
var tim = require('../').tim;
var result = tim("Hello {{place}}", {place: "world"});
assert.equal(result, "Hello world");

@@ -10,3 +10,3 @@ }

exports["path"] = function() {
var tinytim = require('../');
var tim = require('../').tim;
var template = "Hello {{place}}. My name is {{person.name}}.",

@@ -20,3 +20,3 @@ data = {

var result = tinytim.tim(template, data);
var result = tim(template, data);
assert.equal(result, "Hello Brighton. My name is Prem.");

@@ -26,3 +26,3 @@ }

exports["html"] = function() {
var tinytim = require('../');
var tim = require('../').tim;
var template = "<p><a href='{{url}}'>{{title}}</a></p>",

@@ -34,3 +34,3 @@ data = {

var result = tinytim.tim(template, data);
var result = tim(template, data);
assert.equal(result, "<p><a href='http://dharmafly.com'>Dharmafly</a></p>");

@@ -41,3 +41,3 @@ }

exports["nested"] = function() {
var tinytim = require('../');
var tim = require('../').tim;
var ul = "<ul>{{list}}</ul>",

@@ -49,5 +49,5 @@ li = "<li>{{contents}}</li>",

for (i=100; i<103; i++){
myList += tinytim.tim(li, {contents: i});
myList += tim(li, {contents: i});
}
var result = tinytim.tim(ul, {list: myList});
var result = tim(ul, {list: myList});
assert.equal(result, "<ul><li>100</li><li>101</li><li>102</li></ul>");

@@ -57,4 +57,4 @@ }

exports["array"] = function() {
var tinytim = require('../');
var result = tinytim.tim("Hello {{0}}", ["world"]);
var tim = require('../').tim;
var result = tim("Hello {{0}}", ["world"]);
assert.equal(result, "Hello world");

@@ -64,7 +64,14 @@ }

exports["array 2"] = function() {
var tinytim = require('../');
var result = tinytim.tim("Hello {{places.0}}", {places: ["world"]});
var tim = require('../').tim;
var result = tim("Hello {{places.0}}", {places: ["world"]});
assert.equal(result, "Hello world");
}
exports["exception"] = function() {
var tinytim = require('../');
assert.throws(function() {
var result = tim("Hello {{config.foo.bar}}", {config: {moo: "blah"}});
}, Error)
}
exports["start end"] = function() {

@@ -78,1 +85,10 @@ var tinytim = require('../');

exports["start end 2"] = function() {
var tinytim = require('../');
//here the start and end tag was changed at last test case
var result = tinytim.tim("Hello <%place%>", {place: "world"});
assert.equal(result, "Hello world");
}
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