GithubHelp home page GithubHelp logo

webgamelinux / gulp-ejs-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yscoder/gulp-ejs-demo

0.0 3.0 0.0 934 KB

gulp+ejs 合并静态页模版,文件更新自动刷新。

JavaScript 16.77% HTML 83.23%

gulp-ejs-demo's Introduction

gulp-ejs-demo

gulp+ejs 合并静态页模版,文件更新自动热重载。

  • npm install 安装依赖
  • gulp dev 启动一个自动热重载的服务器,默认端口3000
  • gulp ejs 合并模版,服务器启动时会自动监听文件更新执行该任务

流程

  1. 模板编码,即 templates/ 目录,页面入口以 .html 结尾,分支模版以 .ejs 结尾,没有目录结构限制,按需引入或编写新的页面模块。在这个阶段可以启动服务器 gulp dev 进行实时页面预览。

  2. 编写数据文件,分为全局数据文件 global.json 和页面数据文件,使用通用的 json 格式。全局数据文件必须放到模版根目录,一个页面对应一个同名的数据文件同级目录。数据中可以写,比如: title:页面标题styles:依赖的样式文件路径scripts:依赖的脚本文件路径 ,随时可以根据实际情况添加新的数据项。

  3. 执行 gulp ejs 任务,生成页面到 html/ 目录,如果之前启动了热重载服务器不需要这一步。

其他

实际工作中肯定还会搭配其他任务一起运行,比如:css 和 js 相关任务。此 Demo 中省略,可根据各自项目情况自行更改。

gulp-ejs-demo's People

Contributors

yscoder avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.