🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

gulp-inline-template

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-inline-template

Inline template into js file as string or function.

latest
Source
npmnpm
Version
1.1.5
Version published
Weekly downloads
2
-89.47%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-inline-template

Inline template into js file as string or function.

Usage

use __inline(filePath) to inline template to js file as string (Only relative path support);

use __template(filePath) to inline ejs template to js file as function (Only relative path support);

Example

<!-- content.tpl -->
<ul class="ul">
	<% for(var i=0;i<data.list.length;i++) { %>
	<li><%=data.list[i]%></li>
	<% } %>
</ul>
var a = __inline("./content.tpl")
var b = __template("./content.tpl")

//after compile:
var a = "<ul class=\"ul\">\n\t<% for(var i=0;i<data.list.length;i++) { %>\n\t<li><%=data.list[i]%></li>\n\t<% } %>\n</ul>\n";
var b = function(data,escape
/**/) {
escape = escape || function (markup) {
  return markup == undefined
    ? ''
    : String(markup)
        .replace(_MATCH_HTML, encode_char);
};
var _ENCODE_HTML_RULES = {
      "&": "&amp;"
    , "<": "&lt;"
    , ">": "&gt;"
    , '"': "&#34;"
    , "'": "&#39;"
    }
  , _MATCH_HTML = /[&<>'"]/g;
function encode_char(c) {
  return _ENCODE_HTML_RULES[c] || c;
};
;
  var __output = [], __append = __output.push.bind(__output);
    ; __append("<ul class=\"ul\">\n	")
    ;  for(var i=0;i<data.list.length;i++) { 
    ; __append("\n	<li>")
    ; __append(escape(data.list[i]))
    ; __append("</li>\n	")
    ;  } 
    ; __append("\n</ul>\n")
  return __output.join("");

}

Keywords

gulp

FAQs

Package last updated on 26 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts