templatesjs
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "templatesjs", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Render template without any engine, pure JavaScript, high speedy, easy to use, works with any file format including HTML, include files inside files, can be used with any framework and raw node.js ", | ||
@@ -27,3 +27,4 @@ "main": "index.js", | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
} | ||
} |
218
README.md
@@ -7,25 +7,27 @@ # templatesjs | ||
table of contents: | ||
##table of contents: | ||
##installation | ||
|_ | ||
##usage | ||
|_ ##how to render string | ||
|_ ##how to render object.objectvalue | ||
|_ ##how to render specific index's value of an array | ||
|_ ##how to render all values looping through the whole array | ||
|_ ##how to render all values looping through an specific index of array | ||
|_ ##how to specify format of output (other elements around it or nesting it in other elements) | ||
|_ ##specify output to be UPPERCASE, Capitalized or lowercase | ||
|_ ##include another file inside a file or data | ||
|_ ##set default directory for files | ||
|_ #%tip : change the delimiter sign(%) | ||
|_ ##%tip : shorthands for functions | ||
|_ ##*demonstration : using with javascript in client side | ||
- [Install](#install) | ||
- [usage](#usage) | ||
- [render string](#how to render string) | ||
- [render object](#how to render object.objectvalue) | ||
- [rendex array](#how to render specific index's value of an array) | ||
- [loop through array](#how to render all values looping through the whole array) | ||
- [loop through specific array indexes] (#how to render all values looping through an specific index of array) | ||
- [specify format of output] (#how to specify format of output (other elements around it or nesting it in other elements) | ||
- [UPPERCASE, Capitalized, lowercase output](#specify output to be UPPERCASE, Capitalized or lowercase) | ||
- [include files](#include another file inside a file or data) | ||
- [set default directory] (#set default directory for files) | ||
- [change delimiter](#%tip : change the delimiter sign(%)) | ||
- [shorthands for functions] (#%tip : shorthands for functions) | ||
- [demonstration](#*demonstration : using with javascript in client side) | ||
## Installation | ||
`$ npm install templatesjs` | ||
```sh | ||
$ npm install mysql | ||
``` | ||
@@ -46,4 +48,4 @@ | ||
examle HTML(index.html)::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
examle HTML(index.html) | ||
```html | ||
<!DOCTYPE HTML> | ||
@@ -58,8 +60,9 @@ <html> | ||
</html> | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
here we will replace the <%user%> tag with John Doe; | ||
in node.js file ::::::::::::::::::::::::::::::::::::::::::::::::: | ||
in node.js file | ||
```js | ||
var templatesjs = require('templatesjs'); | ||
@@ -75,14 +78,12 @@ | ||
}); | ||
``` | ||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
this will print "HELLO John Doe" on the browser instead of <%user%> | ||
##how to render object.objectvalue | ||
###################################################################################################################################### | ||
we can also render array or object value as | ||
html:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
```html | ||
@@ -94,6 +95,7 @@ | ||
``` | ||
in node.js file | ||
```js | ||
node.js:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
var data = fs.readFileSync("./index.html"); | ||
@@ -104,4 +106,3 @@ templatesjs.set(data); | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
this will print "HELLO John Doe" | ||
@@ -111,3 +112,2 @@ | ||
##how to render specific index's value of an array | ||
###################################################################################################################################### | ||
@@ -117,3 +117,3 @@ for array: | ||
html:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
```html | ||
@@ -125,4 +125,6 @@ | ||
``` | ||
in node.js file | ||
node.js:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
```js | ||
@@ -135,4 +137,3 @@ | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
this will print "HELLO John Doe" | ||
@@ -142,10 +143,8 @@ | ||
##how to render all values looping through the whole array | ||
###################################################################################################################################### | ||
or all values of an array : | ||
```html | ||
html:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
<body> | ||
@@ -155,6 +154,7 @@ HELLO <%user[]%> | ||
``` | ||
in node.js file | ||
```js | ||
node.js:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
var data = fs.readFileSync("./index.html"); | ||
@@ -165,4 +165,3 @@ templatesjs.set(data); | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
this will print "HELLO John Doe18" | ||
@@ -172,10 +171,8 @@ | ||
##how to render all values looping through some specific index of array | ||
###################################################################################################################################### | ||
all array values starting from an index to another one | ||
```html | ||
html:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
<body> | ||
@@ -191,6 +188,6 @@ HELLO <%user[2,5]%> | ||
``` | ||
in node.js file | ||
```js | ||
node.js:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
var data = fs.readFileSync("./index.html"); | ||
@@ -201,4 +198,3 @@ templatesjs.set(data); | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
this will print "18helloworldJS" | ||
@@ -208,3 +204,2 @@ | ||
##how to specify format of output (other elements around it or nesting it in other elements) | ||
###################################################################################################################################### | ||
@@ -214,6 +209,5 @@ suppose that we want a for each loop through our array values | ||
```html | ||
html:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
<body> | ||
@@ -230,5 +224,8 @@ | ||
node.js:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
in node.js file | ||
```js | ||
var data = fs.readFileSync("./index.html"); | ||
@@ -239,4 +236,3 @@ templatesjs.set(data); | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
output : <a href="user/John">John</a> <a href="user/Doe">Doe</a> | ||
@@ -247,6 +243,5 @@ | ||
for a loop through specified indexes of an array in specified format | ||
```html | ||
html:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
<body> | ||
@@ -263,5 +258,8 @@ | ||
node.js:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
in node.js file | ||
```js | ||
var data = fs.readFileSync("./index.html"); | ||
@@ -272,4 +270,3 @@ templatesjs.set(data); | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
output : <a href="user/foo">foo</a> <a href="user/bar">bar</a> <a href="user/example">ecample</a> | ||
@@ -281,6 +278,5 @@ | ||
or specify format for only one array index if you want | ||
```html | ||
html:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
<body> | ||
@@ -297,5 +293,8 @@ | ||
node.js:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
in node.js file | ||
```js | ||
var data = fs.readFileSync("./index.html"); | ||
@@ -306,4 +305,3 @@ templatesjs.set(data); | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
output : <a href="user/foo">foo</a> | ||
@@ -314,3 +312,2 @@ | ||
##specify output to be UPPERCASE, Capitalized or lowercase | ||
###################################################################################################################################### | ||
@@ -325,6 +322,5 @@ you can specify whether the output will be in UPPERCASE, lowercase, Capitalized using a third optional "case" param | ||
```html | ||
html:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
<body> | ||
@@ -338,4 +334,6 @@ | ||
``` | ||
in node.js file | ||
```js | ||
node.js:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
@@ -349,4 +347,3 @@ | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
output : UPPERCASE: JOHN | ||
@@ -358,9 +355,7 @@ Capitalized: Doe | ||
##include another file inside a file or data | ||
###################################################################################################################################### | ||
the templatesjs also has an include feature which can be used to include file or template parts | ||
just use the <%include%> tag in your file | ||
```html | ||
HTML::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
<body> | ||
@@ -381,3 +376,3 @@ | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
@@ -392,6 +387,4 @@ no need to render anything in the node.js file, the files will be rendered automatixally when you | ||
##set default directory for files | ||
###################################################################################################################################### | ||
set default directory: | ||
---------------------------------------------------------------------------- | ||
* set default directory: | ||
@@ -404,4 +397,7 @@ | ||
node.js::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
in node.js file | ||
```js | ||
var templatesjs = require('templatesjs'); | ||
@@ -412,51 +408,46 @@ | ||
templatesjs.set("/*you data goes here*/"); | ||
``` | ||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
## tip : change the delimiter sign(%) | ||
##%tip : change the delimiter sign(%) | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
TIP: | ||
----------------------------------------------------------------------------------- | ||
**TIP:** | ||
Don't like to use the "%" sign to define tags in html page you can change them :D :D :D | ||
use the templatesjs.delim() function | ||
node.js::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
in node.js file | ||
```js | ||
var md = require('templatesjs'); | ||
md.delim("$") // you can use any sign like ["!@#$%^&*"] or any combination like "#@" or "%$" or "*&" or "*!" | ||
``` | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
## tip : shorthands for functions | ||
%tip : shorthands for functions | ||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
another TIP: | ||
**another TIP:** | ||
--------------------------------------------------------------------------------------- | ||
are function names too long? there are shorthands availabe :D :D :D | ||
function can also be used as | ||
........ ........... | ||
set() s() | ||
set() setData() | ||
set() sd() | ||
set() setdata() | ||
**function ** **can also be used as** | ||
render() ren() | ||
render() r() | ||
render() rn | ||
* set() s() | ||
* set() setData() | ||
* set() sd() | ||
* set() setdata() | ||
delim() delimier() | ||
delim() del() | ||
delim() d() | ||
* render() ren() | ||
* render() r() | ||
* render() rn | ||
* delim() delimier() | ||
* delim() del() | ||
* delim() d() | ||
##*demonstration : using with javascript in client side | ||
******************************************************************************************************* | ||
Exceptional Demonstration : | ||
just have a look through the following code snippet: | ||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
## demonstration : using with javascript in client side | ||
** Exceptional Demonstration :** | ||
**just have a look through the following code snippet:** | ||
```html | ||
[index.html] | ||
@@ -486,3 +477,6 @@ <body> | ||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
``` | ||
in node.js file | ||
```js | ||
[index.js] | ||
@@ -511,2 +505,2 @@ | ||
}).listen(8080); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21454
470