Create pages with pre-compiling the templates

后端 未结 2 1486
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-22 08:29

In my current project, my work is only with html and css (HTML skinning). There are many pages which have repeated sections like Header, footer, sharing links etc.<

2条回答
  •  死守一世寂寞
    2020-12-22 09:08

    You can use Jade - node template engine

    It gives option to include external jade files, where in it allows you to insert the contents of one jade file into another

    index.jade:

    doctype html
    html
      include ./includes/head.jade
      body
        h1 My Site
        p Welcome to my super lame site.
        include ./includes/foot.jade
    

    head.jade

    //- includes/head.jade
      title My Site
      script(src='/javascripts/jquery.js')
      script(src='/javascripts/app.js')
    

    foot.jade

    //- includes/foot.jade
    #footer
      p Copyright (c) foobar
    

    Compiles to:

    index.html

    
    
      
        My Site
        
        
      
      
        

    My Site

    Welcome to my super lame site.

提交回复
热议问题