我习惯于使用ASP.NET和visual studio来开发网站。我正在尝试开发一个类似的普通.html网站。我的意思是使用母版页等,所以有代码重用,并可能将这些模板文件部署到一组.html文件。
例如
head.html
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.ui.js" type="text/javascript"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js">header.html
<div data-role="header">
<h1>Page Title</h1>
</div><!-- /header -->footer.html
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->layout.html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
#include(head.html)
</script>
</head>
<body>
<div data-role="page">
#include(header.html)
#include_body()
#include(footer.html)
</div><!-- /page -->
</body>
</html>index.html
<div data-role="content">
<p>Page content goes here.</p>
</div><!-- /content -->并将所有这些合并到一个输出文件中……
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Page Title</h1>
</div><!-- /header -->
<div data-role="content">
<p>Page content goes here.</p>
</div><!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
</body>
</html>真的存在这样的东西吗?我不熟悉红宝石之类的.
发布于 2013-02-09 00:43:34
服务器端包含(SSI)可能会满足您的需求。满足一些基本的服务器要求后,您可以这样做,例如:
<!--#include virtual="includes/my_file.html" -->发布于 2013-02-08 11:48:54
您可以使用一些PHP来使用includes来完成这项工作。
页眉、页脚等可以创建为新的.php文件,您可以在其中放置您希望在中的该部分显示的所有内容。
然后,在假设您的index.php文件中,您可以执行如下操作
<?php
include ('header.php');
?>
<html>
<head>
</head>
<body>
</body>
<?php
include ('footer.php');
?>页眉和页脚PHP文件中的所有内容都将包括在内。
https://stackoverflow.com/questions/14765067
复制相似问题