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

easytemplatejs-express

v3.0.1

Published

EasyTemplateJS Template Engine middleware for koa!

Downloads

3

Readme

EasyTemplateJS-koa

EasyTemplateJS-koa 是基于 EasyTemplateJSExpress 框架的模板引擎中间件。

EasyTemplateJS-koa is a template engine middleware based on EasyTemplateJS](https://github.com/ushelp/EasyTemplateJS "EasyTemplateJS") for the Express framework.

Npm install

npm install easytemplatejs-express 

Usage

const app = express();

// EasyTemplateJS-express
const view = require('easytemplatejs-express');

// EasyTemplateJS-Express view render middleware
view(app, {
    cache: true,  // Whether to open the cache; default is true
    //cache: process.env.NODE_ENV == 'production',
    enableScript:true, // enable <etj-script>; default is true
    enableStyle:true, // enable <etj-style>; default is true
    views: './views'  // template file directory
});

Demo

  • app.js

    const express = require('express')
    const app = express() 
      
    // EasyTemplateJS-express
    const view = require('easytemplatejs-express');
    // EasyTemplateJS-Express view render middleware
    view(app, {
    	views: './views'  // template file directory
    });
      
      
    app.get('/users', function (req, res) {
      res.render('user', {
            name: 'Jay',
    		list:[
     			{name:"Jay", sex:'M'},
     			{name:"Rose", sex:'F'},
     			{name:"Anna ", sex:'F'}
     		]
    	});
    })
      
    app.listen(3000, function () { console.log('App listening on port 3000!') })
    
  • ./views/user.etj

    <h1>Hello {=name}!</h1>
    <ul>
    %{
    	for(var i=0;i<list.length;i++){
    		out('<li>'+list[i].name+", "+list[i].sex+'</li>');	
    	}
    }%
    </ul>

EasyTemplateJS Core Object

如果需要获得 EasyTemplateJS 的核心对象进行调用,可通过中间件函数的 .templateEngine 属性获得。

If you need to get the core object of EasyTemplateJS to make a call, you can get it use the .templateEngine property of the middleware function.

const view = require('easytemplatejs-express');

// Get EasyTemplate core Object
var Et=view.templateEngine;

// Use Et
Et.tmplSettings={
	// 脚本表达式开始结束标记%{ JS script }%
	scriptBegin:"%{",
	scriptEnd:"}%",
	// 输出表达式开始结束标记 {name}
	outBegin:"{=",
	outEnd:"}",
	// 转义输出表达式开始结束标记 {-name}
	escapeOutBegin:"{-",
	escapeOutEnd:"}"
}

内嵌 Script 和 CSS 支持/Embedded JavaScript and CSS

view(app, {
  enableScript:true, // enable <etj-script>; default is true
  enableStyle:true, // enable <etj-style>; default is true
  ...
});

中文

为了增强在 Express 等服务端 Web 应用框架中使用模板的功能体验,EasyTemplateJS 开创性的为模板提供了 script 脚本和 style 样式表支持。

  • Script 代码支持

    将 JavaScript 代码放在 <etj-script> ... </etj-script> 标签之间。 语句必须使用 ; 结尾。

  • CSS 代码支持

    将 CSS 代码放在 <etj-style> ... </etj-style> 标签之间。

English

To enhance the functional experience of using templates in Express and other server-side Web application frameworks, EasyTemplateJS pioneered the provision of script scripts and style style sheet support for templates.

  • Script code support

    Place the JavaScript code between the <etj-script> ... </etj-script> tags. The statement must end with ;.

  • CSS code support

    Place the CSS code between the <etj-style> ... </etj-style> tags.

EasyTemplateJS

Documents

End

Email:[email protected]

http://www.easyproject.cn

支付宝钱包扫一扫捐助:

我们相信,每个人的点滴贡献,都将是推动产生更多、更好免费开源产品的一大步。

感谢慷慨捐助,以支持服务器运行和鼓励更多社区成员。

We believe that the contribution of each bit by bit, will be driven to produce more and better free and open source products a big step.

Thank you donation to support the server running and encourage more community members.

PayPal