dow58115 2015-04-28 05:07
浏览 42

打包HTML模板,JavaScript和CSS,以供多个平台使用

I have a large rails application that I am wanting to split out into smaller applications. The one piece of this application that will be universal to all smaller applications is the mast and footer. I would like to extract the html, javascript and css for the mast and footer into it's own package that each app can load and render.

The main issue I'm running into is that the apps will likely not all be written in rails. Some will be rails, some will be expressjs, some written in Go, and some may end up being written in other languages, so my solution needs to be language agnostic.

My thought is that I can extract the html, css and javascript into it's own git repo, use mustache templates for the html, and then use grunt or a similar build tool to build a gem, a package.json structure and a golang module. Possibly each in it's own git submodule.

I'm curious if there is a more standardized way of doing this. Or if anyone knows of a simpler way of achieving this goal.

  • 写回答

1条回答 默认 最新

  • dongruo0909 2015-04-28 18:40
    关注

    Sounds like the technology in common is HTML/JS/CSS.

    Wouldn't it be better to export the mast and footer as a self contained JS library, or more precisely, as widgets?

    So whatever the application server tech stack would be, you could always generate the HTML in the form of:

    <script src="your_widgets.js"></script>
    <script>new Footer.render('id_of_dom_element_to_render_to');</script>
    

    By doing so, whether you want the widget library to load the template or you want to embed the template into the widget library or whether you want to simply just construct it using HTMLFragment will not be limited by the server tech choice.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料