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 🙏

© 2024 – Pkg Stats / Ryan Hefner

xtpl-deps-fix

v3.4.0

Published

nodejs wrapper around xtemplate engine

Downloads

4

Readme

xtpl

nodejs wrapper around xtemplate engine (easier for expressjs and koajs)

xtpl NPM downloads Build Status Coverage Status Dependency Status

docs

syntax

refer: https://github.com/xtemplate/xtemplate

api

methods

config or get xtpl global option:
Object config(option:Object)

option details:

if options is undefined, then this method will return global config.

render file
void renderFile(path:String, options:Object, callback:function)

parameter details:

npm install xtpl xtemplate --save
var xtpl = require('xtpl');
xtpl.renderFile('./x.xtpl',{
	x:1
},function(error,content){

});
express adaptor
xtpl.__express = xtpl.renderFile
clear cache

clear xtemplate cache cached by xtpl file path

void clearCache(path:String);

use for expressjs

var app = require('express')();
app.set('views','./views');
app.set('view engine', 'xtpl');
app.use(function(req, res){
    res.render('test',{data:1});
});

use for koa

var app = require('xtpl/lib/koa')(require('koa')(),{
    views:'./views'
});
app.use(function*(){
    yield this.render('test',{data:1});
});

use for koa2

const koa = require('koa'),
    app = new koa()
const xtpl = require('xtpl/lib/koa2')
    xtpl(app, {
        views:'./views'
    });
app.use(async (ctx, next) => {
    ctx.body = await ctx.render('test',{data:1});
});

Example

├── footer.xtpl
├── header.xtpl
├── index.xtpl
├── layout.xtpl
├── layout1.xtpl
└── sub
    └── header.xtpl

index.xtpl

{{extend ("./layout1")}}

{{#block ("head")}}
<!--index head block-->
<link type="text/css" href="test.css" rev="stylesheet" rel="stylesheet"  />
{{/block}}

{{#block ("body")}}
<!--index body block-->
<h2>{{title}}</h2>
{{/block}}

layout1.xtpl

<!doctype html>
<html>
<head>
<meta name="charset" content="utf-8" />
<title>{{title}}</title>
{{{block ("head")}}}
</head>
<body>
{{{include ("./header")}}}
{{{block ("body")}}}
{{{include ("./footer")}}}
</body>
</html>

render

res.render("index", {title: "xtpl engine!"})

output

<!doctype html>
<html>
<head>
<meta name="charset" content="utf-8" />
<title>xtpl engine!</title>

<!--index head block-->
<link type="text/css" href="test.css" rev="stylesheet" rel="stylesheet"  />

</head>
<body>
<h1>header</h1>
<h2>sub header</h2>

<!--index body block-->
<h2>xtpl engine!</h2>

<h1>footer</h1>

</body>
</html>

changelog

https://github.com/xtemplate/xtpl/milestones

License

xtpl is released under the MIT license.