zoukankan      html  css  js  c++  java
  • 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是一个很不错的工具,可以和容器集成起来,搞一个灵活的配置部署系统

    参考资料

    https://github.com/mig1984/bashible

  • 相关阅读:
    nyist 541最强DE 战斗力
    nyist 231 Apple Tree
    nyist 543 遥 控 器
    nyist 233 Sort it
    nyist 517 最小公倍数
    hdu 1sting
    nyist A+B Problem IV
    nyist 522 Interval
    nyist 117 求逆序数
    nyist 600 花儿朵朵
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/12567361.html
Copyright © 2011-2022 走看看