New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

plugin-gff-thymeleaf-html

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plugin-gff-thymeleaf-html

build-scripts plugin template for developers

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

用途

用途, 用于 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"

基础扩展

@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

FAQs

Package last updated on 25 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts