bashible 模版使用
bashible 内置了一个模版系统,使用灵活,可以用来方便的生成html 页面,官方提供了一个比较完备的demo
可以学习
generating_html_from_a_template
- 项目结构
├── README
├── generate.bash
├── index.html
├── index.tpl
├── js
│ ├── bar.js
│ └── foo.js
└── parts
├── body.tpl
└── head.tpl
- 项目说明
.tpl的都是模版引擎,index.tpl 为入口,body.tpl ,head.tpl为片段的,index.tpl 聚合片段
index.tpl
<html>
<head>
$( template parts/head.tpl )
</head>
<body>
$( template parts/body.tpl )
</body>
</html>
head.tpl
js 内容替换,使用了变量 FOO_OR_BAR
<script type='text/javascript'>
$( cat js/$FOO_OR_BAR.js )
</script>
body.tpl
时间替换
<h1> Now is $( date ) </h1>
生成模版bash
generate.bash
#!/usr/local/bin/bashible
use template
# this variable is used to include either foo.js or bar.js in the HTML head (see parts/head.tpl template)
FOO_OR_BAR=bar #foo
@ Building the HTML from a template
- output_to index.html template index.tpl
运行
- 命令
./generate.bash
- 效果
说明
对于不太懂shell 编程的人员来说bashible是一个很不错的工具,可以和容器集成起来,搞一个灵活的配置部署系统
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2019-03-25 terraform plugin 版本以及changlog 规范
2019-03-25 Terraform Detecting Drift
2019-03-25 使用terraform-provider-s3 操作minio
2019-03-25 Terraform 自定义provider 开发
2019-03-25 Writing Custom Providers
2017-03-25 luarocks 安装
2017-03-25 几个中文排版web 类库