2015-05-16 40 views
0

如何在express.js中包含我的html/js/css文件? 有沒有什麼辦法可以管理模板?如何在express.js中集成HTML模板

我想只使用HTML(無玉)。

<head> 
     <DATA> 
    </head> 
    <header> 
     <?php include('includes/header.html'); ?> 
    </header> 
    <topnavigation> 
     <?php include('top_navigation/header.html'); ?> 
    </topnavigation> 

    <content> 
     <?php include('website/header.html'); ?> 
    </content> 

    <footer> 
     <?php include('includes/content.html'); ?> 
    </footer> 
+0

您是否嘗試過尋找一些樣品應用? –

+0

告訴我們您嘗試過的以及爲什麼 它不符合您的需求。這表明你已經花時間 試圖幫助自己,它使我們避免重申明顯的答案, ,最重要的是它可以幫助您獲得更具體和相關的答案! 另請參閱[如何問](http://stackoverflow.com/questions/how-to-ask) –

回答

0

Follow this tutorial

在本教程中 .ejs模板引擎

使用,但你只需要改變的只有一件事後更換.ejs.html

改變這一行: -

// set the view engine to ejs 
app.set('view engine', 'ejs'); 

本: -

app.engine('html', require('ejs').renderFile); 

多數民衆贊成現在你可以使用純html頁模板引擎

+0

謝謝,我會通過它... –

+0

有許多Nodejs的模板選項。你應該找到一個你感到滿意的 - 可能會有一個像你在PHP中看到的那樣。我使用SWIG,因爲它基於我喜歡的Django系統... – akaphenom

+0

@akaphenom我知道有很多,但他需要不直接支持的純HTML模板引擎。 –

相關問題