Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fouber/fis-parser-ejs
a parser plugin for fis to compile ejs file
https://github.com/fouber/fis-parser-ejs
Last synced: 5 days ago
JSON representation
a parser plugin for fis to compile ejs file
- Host: GitHub
- URL: https://github.com/fouber/fis-parser-ejs
- Owner: fouber
- License: mit
- Created: 2013-12-17T11:49:17.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-17T11:59:01.000Z (almost 11 years ago)
- Last Synced: 2024-10-07T08:14:50.978Z (about 1 month ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# fis-parser-ejs
a parser plugin for fis to compile ejs file
## usage
1. install
```bash
npm install -g fis-parser-ejs
```1. configure
```javascript
//tell fis that `.ejs` is a js file
fis.config.set('roadmap.ext.ejs', 'js');
//tell fis that parse `.ejs` file by using `fis-parser-ejs` plugin
fis.config.set('modules.parser.ejs', 'ejs');
//set options if you need
//@see https://github.com/visionmedia/ejs#options
fis.config.set('settings.parser.ejs', {
open : '<#',
close : '#>'
});
```1. inline ejs file
* source:
```javascript
/**********************************
* tpl.ejs content:
**********************************
<% if (user) { %>
<%= user.name %>
<% } %>
**********************************/
var tpl = __inline('tpl.ejs');
var data = {
user : {
name : 'foo'
}
};
var html = tpl(data);
console.log(html);
```
* release:
```javascript
var tpl = [function(locals,filters,escape,rethrow){function rethrow(e,n,a,t){var r=n.split("\n"),s=Math.max(t-3,0),c=Math.min(r.length,t+3),i=r.slice(s,c).map(function(e,n){var a=n+s+1;return(a==t?" >> ":" ")+a+"| "+e}).join("\n");throw e.path=a,e.message=(a||"ejs")+":"+t+"\n"+i+"\n\n"+e.message,e}escape=escape||function(e){return String(e).replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")};var __stack={lineno:1,input:"<% if (user) { %>\n<%= user.name %>
\n<% } %>",filename:"a.ejs"};try{var buf=[];with(locals||{})!function(){buf.push(""),__stack.lineno=1,user&&(buf.push("\n",escape((__stack.lineno=2,user.name)),"
\n"),__stack.lineno=3),buf.push("")}();return buf.join("")}catch(err){rethrow(err,__stack.input,__stack.filename,__stack.lineno)}}][0];
var data = {
user : {
name : 'foo'
}
};
var html = tpl(data);
console.log(html);
```