npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gulp-template-xm

v0.1.0

Published

simple template engine

Readme

gulp-template-xm

html template

Usage

First, install gulp-template-xm as a development dependency:

npm install --save-dev gulp-template-xm

Then, add it to your gulpfile.js:

Simple Example

Gulpfile

var tplprocesser = require('gulp-template-xm');

gulp.task('html', function() {
	gulp.src(['/**/*.html', "!/template/**/*.html"])
		.pipe(tplprocesser())
		.pipe(gulp.dest(".tmp/"));
});

html

####index.tpl.html

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>#{title}</title>
	
	#{css}
	
</head>
<body>

	#{content}
	
	#{js}

</body>
</html>

user.html

<!-- tpl 
	{
		"parent": "template/index.tpl.html", "css": "/styles/user.css, /style/default.css", 
		"title": "this is user profile page", "js": "/script/config.js, /scripts/user.js", 
		"user":"[email protected]"
		//other variable
	} 
-->
<!--begin user page -->
<div class="container">
	<h1>my profile</h1>
	<span>#{user}</span>
	.....
</div><!--end user page-->

result: user.html

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>this is user profile page</title>

	<link rel="stylesheet" href="/styles/user.css">
	<link rel="stylesheet" href="/styles/default.css">

</head>
<body>
	<!--begin user page -->
	<div class="container">
		<h1>my profile</h1>
		<span>github.com/tuxming</span>
		.....
	</div><!--end user page-->
	
	<script type="text/javascript" src="/scripts/config.js"></script>
	<script type="text/javascript" src="/scripts/user.js"></script>
	
</body>
</html>

##Expand Example

Gulpfile

var tplprocesser = require('gulp-template-xm');
var fs = require('fs');
var inject = require('gulp-inject-xm');

var paths = {bowerjs:[
	'./bower_components/jquery/dist/jquery.js',
	'./bower_components/angular/angular.js',
	'./bower_components/bootstrap/dist/js/bootstrap.js'
]}

var processCallback() = function (info, isDebug){
	if(info.type == "tpl"){
		var source = fs.readFileSync(config.app+"/"+info.ref);
		if(source)
			return source.toString();
		else 
			return "";
	}else if(info.type=='bower'){
		var bowerjss;
		if(isDebug){
			bowerjss = paths.bowerjs.map(function(item, i){
				var paths = item.split("/");
				var jsName = paths[paths.length-1];
				return "<script type='text/javascript' src='/scripts/public/"+jsName+"'></script>";
			}).reduce(function(a, b){
				return a+b; 
			});	
		}else{
			bowerjss = "<script type='text/javascript' src='scripts/vender.js' ></script>";
		}
		
		return bowerjss;
		
	}else
		return "";
}

gulp.task('html', function() {
	gulp.src(['/**/*.html', '!/template/**/*.html'])
		.pipe(inject.process({  //inject to user.html 
			isDebug : false, //product, true: developer -> can't inject css, js
			callback: processCallback
		}))
		.pipe(tplprocesser({  //add template to user.html
			tplProcess: function(templatefile){  //inject to template {index.tpl.html}
				return inject.processHtmlForString(templatefile.toString(), {
					isDebug: false,  //product, true: developer -> can't inject css, js
					callback: processCallback
				});
			}
		}))
		//.pipe(htmlref(jsprocess, cssprocss));  //see gulp-process-ref
		.pipe(gulp.dest(".tmp/"))
});

html

user.html

<!-- tpl 
	{	
		"parent": "index.tpl.html", "css": "/styles/user.css, /style/default.css", 
		"title": "this is user profile page"
		"user":"[email protected]",
		"jsref": "<span class='buildjs' name='main.js' dist='/scripts/' ><script type='text/javascript' class='concat' base='../..' src='../../script/main.js'></script><script type='text/javascript' class='concat' base='../..' src='../../script/config.js'></script>"
	} 
-->
<!--begin user page -->
<div class="container">
	<h1>my profile</h1>
	<span>#{user}</span>
	
	.....
</div><!--end user page-->


index.tpl.html

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>#{title}</title>
	
	<!-- build {"type":"css", "ref":"styles/main.css"} -->
	<link rel="stylesheet" href="../styles/main.css">
	<link rel="stylesheet" href="../styles/style.css">
	<!-- endbuild -->
	#{css}
	
</head>
<body>
	<!--build {"type":"tpl", "ref":"template/header.html"}-->
	<!--endbuild-->
	
	#{content}
	
	<!--build {"type":"tpl", "ref":"template/footer.html"}-->
	<!--endbuild-->
	
	<!-- build {"type":"bower" }-->
	<!-- endbuild -->

</body>
</html>	
	
	

header.html
<!--page header-->
<div class="header">this is page head</div>

footer.html
<!--page footer-->
<div class="header">this is page footer</div>
	

result user.html(isDubug:false)

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>#{title}</title>
	
	<!-- build {"type":"css", "ref":"styles/main.css"} -->
	<link rel="stylesheet" href="../styles/main.css">
	<link rel="stylesheet" href="../styles/style.css">
	<!-- endbuild -->
	<link rel="stylesheet" href="../styles/user.css">
	<link rel="stylesheet" href="../styles/default.css">
	
</head>
<body>
	<!--page header-->
	<div class="header">this is page head</div>
	
	<!--begin user page -->
	<div class="container">
		<h1>my profile</h1>
		<span>[email protected]</span>
		
		.....
	</div><!--end user page-->
	
	<!--page footer-->
	<div class="header">this is page footer</div>
	
	<script type='text/javascript' src='/scripts/public/jquery.js'></script>
	<script type='text/javascript' src='/scripts/public/bootstrap.js'></script>
	<script type='text/javascript' src='/scripts/public/angular.js'></script>
	
	<span class='buildjs' name='main.js' dist='/scripts/' >
	<script type='text/javascript' class='concat' base='../..' src='../../script/main.js'></script>
	<script type='text/javascript' class='concat' base='../..' src='../../script/config.js'></script>

</body>
</html>	

result user.html(isDubug:true)

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>#{title}</title>
	
	<link rel="stylesheet" href="styles/main.css">
	
	<link rel="stylesheet" href="../styles/user.css">
	<link rel="stylesheet" href="../styles/default.css">
	
	#{css}
	
</head>
<body>
	<!--page header-->
	<div class="header">this is page head</div>
	
	<!--begin user page -->
	<div class="container">
		<h1>my profile</h1>
		<span>[email protected]</span>
		
		.....
	</div><!--end user page-->
	
	<!--page footer-->
	<div class="header">this is page footer</div>
	
	<script type='text/javascript' src='scripts/vender.js'></script>
	
	
	// <-- here use gulp-process-ref
	<span class='buildjs' name='main.js' dist='/scripts/' >
	<script type='text/javascript' class='concat' base='../..' src='../../script/main.js'></script>
	<script type='text/javascript' class='concat' base='../..' src='../../script/config.js'></script>

</body>
</html>