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

@aligov/plugin-gff-thymeleaf-html

v2.0.11

Published

build-scripts plugin template for developers

Downloads

9

Readme

用途

用途, 用于 gff 的 thymeamf 模板渲染。 npm start时候, 会被渲染成为 html, npm run build时候会被把 thymleaf 模板做预处理, 保持模板输出。

使用方式

本地安装 tnpm i @ali/plugin-gff-thymeleaf-html -D 然后再 build.json 中添加配置

"plugins": [
    ....
    '@ali/plugin-gff-thymeleaf-html',
    ....
],

也可以增加参数

[
      "@ali/plugin-gff-thymeleaf-html",
      {
        "data": "index.json",
        "filename": "indexV2.html",
      },
],

| 参数名 | 作用 | 类型 | 默认值 | 备注 | | -------- | ------------------------------------------- | ------ | ------------ | --------------------------------------- | | data | 用于 thymleaf 模板渲染的数据 json 地址 | string | "" | 默认使用 npm 包内置的 tempate/data.json | | filename | 构建后的文件名, | string | "index.html" | | 只在 npm run build 时候生效 |

基础扩展

@ali/plugin-gff-thymeleaf-html 内置扩展点,可以方便进行扩展。

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- 其他代码 -->
    <!-- gff-thymleaf:head -->
</head>
<body>
  <!-- gff-thymleaf:bodyBefore -->
  <!-- 其他代码 -->
  <!-- gff-thymleaf:bodyAfter -->
</body>
</html>

例如想要在 html头部插入额外HTML 代码片段, 可以在根目录编写一个 head.html。

<script>
   // head.html文件内容
  console.log('head inject');
</script>

并这增加配置

[
      "@ali/plugin-gff-thymeleaf-html",
      {
        // 其他配置....

        "fragments": {
            "head": "head.html"
        }
      },
],

那么原模板会被渲染为

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- 其他代码 -->
    <script>
        // head.html文件内容
        console.log('head inject');
    </script>
</head>
<body>
  <!-- gff-thymleaf:bodyBefore -->
  <!-- 其他代码 -->
  <!-- gff-thymleaf:bodyAfter -->
</body>
</html>

| 参数名 | 作用 | 类型 | 默认值 | 备注 | | -------- | ------------------------------------------- | ------ | ------------ | --------------------------------------- | | fragments | 扩展点配置 | Map<string, string> | {} | 目前支持的key为head / bodyBefore / bodyAfter |

高级扩展

如果想要彻底定制模板, 可以自行写一个模板 foo-bar.html

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <!-- balabalabla -->
</head>
<body>
    <!-- balabalabla -->
</body>
</html>

并修改配置项 template, 即可使用。

[
      "@ali/plugin-gff-thymeleaf-html",
      {
        // 其他配置....

        "template": "foo-bar.html"
      },
],

| 参数名 | 作用 | 类型 | 默认值 | 备注 | | -------- | ------------------------------------------- | ------ | ------------ | --------------------------------------- | | template | 模板地址 | string | "" | 默认使用包内置的 tempate/index.thymleaf.html |