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

templatesjs

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

templatesjs - npm Package Compare versions

Comparing version 1.9.9 to 1.9.99

2

package.json
{
"name": "templatesjs",
"version": "1.9.9",
"version": "1.9.99",
"description": "Render template dynamically , works with any file format including HTML",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -220,5 +220,7 @@ # templatesjs

render("keyword","value", cb)
keyword - [REQUIRED] - the keyword of the tag (e.g.: `user` if the tag is `<%user%>`);
Value - [REQUIRED] - the value of the keyword (e.g.: `John` for variable/keyword `user`);
cb - [REQUIRED] - a callback to be fired once the changes have been made. If cb is not specified, an error will be thrown.
keyword - [REQUIRED] - the keyword of the tag ;
Value - [REQUIRED] - the value of the keyword ;
cb - [REQUIRED] - a callback to be fired once the changes have been made.
If cb is not specified, an error will be thrown.
err - First parameter to the callback detailing any errors.

@@ -229,8 +231,12 @@ data - the processed data with changes made in it.

renderSync("keyword","value")
keyword - [REQUIRED] - the keyword of the tag (e.g.: `user` if the tag is `<%user%>`);
Value - [REQUIRED] - the value of the keyword (e.g.: `John` for variable/keyword `user`);
keyword - [REQUIRED] - the keyword of the tag ;
Value - [REQUIRED] - the value of the keyword ;
renderAll(list, cb)
list - [REQUIRED] - an object with the list of variable to render, variable names as property and values as property value;
cb - [REQUIRED] - a callback to be fired once the changes have been made. If cb is not specified, an error will be thrown.
list - [REQUIRED] - an object with the list of variable to render,
variable names as property and values as property value;
cb - [REQUIRED] - a callback to be fired once the changes have been made.
If cb is not specified, an error will be thrown.
err - First parameter to the callback detailing any errors.

@@ -241,7 +247,9 @@ data - the processed data with changes made in it.

renderAllSync(list, cb)
list - [REQUIRED] - an object with the list of variable to render, variable names as property and values as property value;
list - [REQUIRED] - an object with the list of variable to render, variable
names as property and values as property value;
set(data, cb)
data - [REQUIRED] - the data to work with (e.g.: data read from index.html)
cb - [REQUIRED] - a callback to be fired once the changes have been made. If cb is not specified, an error will be thrown.
cb - [REQUIRED] - a callback to be fired once the changes have been made.
If cb is not specified, an error will be thrown.
err - First parameter to the callback detailing any errors.

@@ -253,9 +261,11 @@ data - the processed data with changes made in it.

Look here for [Shorthands for functions](#shorthands-for-functions)
#Detail Usage
You can render view using four diiferent functions `render(), renderSync(), renderAll(), renderAllSync()`.
read a file, set the data using `set()` and render it using you favourite one.
You can render view using four diiferent functions `render(), renderSync(),
renderAll(), renderAllSync()`.
read a file, set the data using `set()` and render it using you favourite
one.
We will Walk through examples for each data type and diiferent cases to handle them.
We will Walk through examples for each data type and diiferent cases to handle
them.

@@ -262,0 +272,0 @@ ##string

@@ -8,3 +8,3 @@ 'use strict';

it('should replace the <%user%> tag with "imtiaz"', function() {
it('should replace the <%user%> tag with "imtiaz" using renderSync()', function() {
templatesjs.setSync("<%user%>");

@@ -15,3 +15,14 @@ var result = templatesjs.renderSync("user", "imtiaz");

it('should replace the <%user%> tag with "imtiaz"', function() {
it('should replace the <%user%> tag with "imtiaz" using render()', function() {
templatesjs.set("<%user%>", function(err,data){
if(err) throw err;
templatesjs.render("user", "imtiaz", function(err,result){
if(err) throw err;
expect(result).to.equal('imtiaz');
});
});
});
it('should replace the <%user%> tag with "imtiaz" using renderSync() when style specified as "case" ', function() {
templatesjs.setSync("<%user%>");

@@ -22,3 +33,14 @@ var result = templatesjs.renderSync("user", "iMTiaz", "case");

it('should replace the <%user%> tag with "IMTIAZ"', function() {
it('should replace the <%user%> tag with "imtiaz" using render() when style specified as "case"', function() {
templatesjs.set("<%user%>", function(err,data){
if(err) throw err;
templatesjs.render("user", "iMtiaz", "case", function(err,result){
if(err) throw err;
expect(result).to.equal('imtiaz');
});
});
});
it('should replace the <%user%> tag with "IMTIAZ" using renderSync() when style specified as "CASE"', function() {
templatesjs.setSync("<%user%>");

@@ -29,3 +51,3 @@ var result = templatesjs.renderSync("user", "imtiaz", "CASE");

it('should replace the <%user%> tag with "Imtiaz"', function() {
it('should replace the <%user%> tag with "Imtiaz" using renderSync() when style specified as "Case"', function() {
templatesjs.setSync("<%user%>");

@@ -78,3 +100,2 @@ var result = templatesjs.renderSync("user", "imtiaz","Case");

it('should replace the <%include test.txt%> tag with "templatesjs"', function() {
templatesjs.logErr = true;
templatesjs.dir = "./test/"

@@ -86,2 +107,26 @@ var result = templatesjs.setSync("<%include test.txt %>");

it('should replace the <%firstname%><%lastname%><%email%> with "JohnDoeJohn@Doe.com" using renderAllSync()', function() {
templatesjs.setSync("<%firstname%><%lastname%><%email%>");
var list = {
firstname:"John",
lastname:"Doe",
email:"John@Doe.com"
}
var result = templatesjs.renderAllSync(list);
expect(result).to.equal('JohnDoeJohn@Doe.com');
});
it('should replace the <%firstname%><%lastname%><%email%> with "JohnDoeJohn@Doe.com" using renderAll()', function() {
templatesjs.setSync("<%firstname%><%lastname%><%email%>");
var list = {
firstname:"John",
lastname:"Doe",
email:"John@Doe.com"
}
templatesjs.renderAll(list, function(err,result){
if(err) throw err;
expect(result).to.equal('JohnDoeJohn@Doe.com');
});
});
});
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