manila
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -45,3 +45,3 @@ 'use strict'; | ||
let match = /<-\s*?include\s(\S*?)\s*?->/i.exec(template), | ||
let match = /<:\s*?include\s(\S*?)\s*?:>/i.exec(template), | ||
ext = new RegExp(opts.extension + '$'), | ||
@@ -48,0 +48,0 @@ raw, include; |
{ | ||
"name": "manila", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "A simple template engine for Node", | ||
@@ -5,0 +5,0 @@ "main": "manila.js", |
@@ -12,8 +12,8 @@ 'use strict'; | ||
.replace(/`/g, "\\`") | ||
.replace(/<--(?!\s*}.*?-->)(?!.*{\s*-->)(.*?)-->/g, "`);try{p.push($1)}catch(e){}p.push(`") | ||
.replace(/<--\s*(.*?)\s*-->/g, "`);$1\np.push(`") | ||
.replace(/<-(?!\s*}.*?->)(?!.*{\s*->)(.*?)->/g, "`);try{p.push(manila.e($1))}catch(e){}p.push(`") | ||
.replace(/<-\s*(.*?)\s*->/g, "`);$1\np.push(`") | ||
.replace(/<::(?!\s*}.*?::>)(?!.*{\s*::>)(.*?)::>/g, "`);try{p.push($1)}catch(e){}p.push(`") | ||
.replace(/<::\s*(.*?)\s*::>/g, "`);$1\np.push(`") | ||
.replace(/<:(?!\s*}.*?:>)(?!.*{\s*:>)(.*?):>/g, "`);try{p.push(manila.e($1))}catch(e){}p.push(`") | ||
.replace(/<:\s*(.*?)\s*:>/g, "`);$1\np.push(`") | ||
+ "`);}return p.join('');"); | ||
}; |
@@ -35,3 +35,3 @@ # Manila | ||
<!-- views/index.mnla --> | ||
<h1><-message-></h1> | ||
<h1><:message:></h1> | ||
``` | ||
@@ -51,5 +51,5 @@ | ||
manila('index.mnla', { message: 'Hello, world!' }, function(err, html) { | ||
res.writeHead(200, 'text/html; charset=UTF-8'); | ||
res.end(html); | ||
}); | ||
res.writeHead(200, 'text/html; charset=UTF-8'); | ||
res.end(html); | ||
}); | ||
@@ -61,3 +61,3 @@ }).listen(3000); | ||
<!-- views/index.mnla --> | ||
<h1><-message-></h1> | ||
<h1><:message:></h1> | ||
``` | ||
@@ -95,3 +95,3 @@ | ||
`partials`: the directory in which to look for partial mnla files to use with `<-include ... ->` tags, realtive to the root. Defaults to `views`. | ||
`partials`: the directory in which to look for partial mnla files to use with `<: include ... :>` tags, realtive to the root. Defaults to `views`. | ||
@@ -112,9 +112,9 @@ `extension`: the file extension of your views/partials. Defaults to `'.mnla'`. | ||
`<- expression ->`: This tag will be replaced with the HTML-escaped result of evaluating the expression or variable with the current context. | ||
`<:expression:>` This tag will be replaced with the HTML-escaped result of evaluating the expression or variable with the current context. | ||
`<-- expression -->`: Use two dashes instead of one to prevent HTML-escaping of the expression. | ||
`<::expression::>` Use two colons instead of one to prevent HTML-escaping of the expression. | ||
## Includes | ||
`<- include path/to/file ->`: Includes the content of the named file as part of the current template. `path/to/file` is relative to `views/` unless overwritten during configuration. | ||
`<: include path/to/file :>` Includes the content of the named file as part of the current template. `path/to/file` is relative to `views/` unless overwritten during configuration. | ||
@@ -127,7 +127,7 @@ ## Blocks | ||
``` | ||
<- if (expression) { -> | ||
<: if (expression) { :> | ||
<p>This markup renders if expression is truthy</p> | ||
<- } else { -> | ||
<: } else { :> | ||
<p>This markup renders if expression is falsy</p> | ||
<- } -> | ||
<: } :> | ||
``` | ||
@@ -138,5 +138,5 @@ | ||
``` | ||
<- list.forEach(item => { -> | ||
<li><-item-></li> | ||
<- }) -> | ||
<: list.forEach(item => { :> | ||
<li><:item:></li> | ||
<: }) :> | ||
``` | ||
@@ -147,5 +147,5 @@ | ||
``` | ||
<- for (key in obj) { -> | ||
<li> <-key-> is <-obj[key]-> </li> | ||
<- } -> | ||
<: for (key in obj) { :> | ||
<li> <:key:> is <:obj[key]:> </li> | ||
<: } :> | ||
``` |
12212
6