问题描述:

I have a Javascript template in Jade:

script.

bla

bla

I wish I could include some js code coming from a file called 'inc.jade' containing just this:

bli

It seems that this code fails:

script.

bla

include inc.jade

bla

What is the correct way to include inc.jade into my script. tag ?

网友答案:

A suggestion for this scenerio: You should put your JS into each seperate file and include that js file where ever required.

The latest release of Jade adds mixins and includes,you can include existing jade as :

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

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

    includes/head.jade:        
    head
      title My Site        
      script(src='/javascripts/jquery.js')
      script(src='/javascripts/myCustom.js') <<------- include it where you need
      script(src='/javascripts/app.js')
相关阅读:
Top