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

ruoyi-eggjs-handlebars

v1.1.5

Published

Egg plugin for handlebars

Downloads

25

Readme

ruoyi-eggjs-handlebars

Egg plugin for handlebars

安装

$ npm i ruoyi-eggjs-handlebars --save

支持的 egg 版本

| egg 3.x | egg 2.x | egg 1.x | | ------- | ------- | ------- | | 😁 | 😁 | ❌ |

开启插件

// {app_root}/config/plugin.js
exports.handlebars = {
  enable: true,
  package: "ruoyi-eggjs-handlebars",
};

配置

// {app_root}/config/config.default.js
config.handlebars = {
  options: {
    data: true,
    compat: true,
    knownHelpers: true,
    knownHelpersOnly: false,
    noEscape: false,
    strict: false,
    assumeObjects: false,
    preventIndent: true,
    ignoreStandalone: true,
    explicitPartialContext: true
  },
  runtimeOptions: {
    allowProtoMethodsByDefault: true,
    allowProtoPropertiesByDefault: true
  },
  partialsPath: null, // 默认在 view.root 对应的 partials 目录下
  ts: true, // CSS、JavaScript 外部资源引用是否添加时间戳
};

更多配置说明请参考 Handlebars 官方文档

示例

基本使用

// controller
async index() {
  const { ctx } = this;
  await ctx.render('index.html', {
    title: 'Hello Handlebars',
    name: 'World'
  });
}

模板文件

<!-- app/view/index.html -->
<!DOCTYPE html>
<html>
<head>
  <title>{{title}}</title>
</head>
<body>
  <h1>Hello {{name}}!</h1>
</body>
</html>

内置 Helper

xif - 条件判断

{{#xif "age > 18"}}
  <p>成年人</p>
{{else}}
  <p>未成年</p>
{{/xif}}

math - 数学运算

{{math value "+" 10}}
{{math value "-" 5}}
{{math value "*" 2}}
{{math value "/" 2}}
{{math value "%" 3}}

link - 引入 CSS

{{link "/static/css/style.css"}}
<!-- 输出: <link rel="stylesheet" href="/static/css/style.css"> -->

script - 引入 JS

{{script "/static/js/app.js"}}
<!-- 输出: <script src="/static/js/app.js"></script> -->

Partials (代码片段)

app/view/partials/ 目录下创建代码片段:

<!-- app/view/partials/header.html -->
<header>
  <h1>{{title}}</h1>
</header>

在模板中使用:

{{> header}}

关于 ruoyi-eggjs 项目

本插件是 ruoyi-eggjs 项目的核心组件之一。

ruoyi-eggjs 是一个基于 Egg.js 的企业级后台管理系统,参照若依(RuoYi)架构设计,提供完善的权限管理、用户管理、系统监控等功能,是快速开发企业级应用的最佳选择。

主要特性

  • 🎯 完整的权限系统:基于 RBAC 的权限控制,支持细粒度权限管理
  • 🚀 开箱即用:集成常用功能模块,快速启动项目开发
  • 🔧 MyBatis 风格:采用 XML 风格的 SQL 编写,熟悉的开发体验
  • 📦 模块化设计:松耦合的插件体系,按需使用
  • 🛡️ 企业级安全:XSS 防护、SQL 注入防护、访问控制等
  • 📊 系统监控:在线用户、登录日志、操作日志、定时任务等

项目地址

相关插件

联系方式

贡献指南

欢迎提交 Issue 和 Pull Request!

如果这个项目对你有帮助,请给我们一个 ⭐️ Star 支持一下!


License

MIT