Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
- Loading branch information
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/gin-contrib/multitemplate" | ||
|
||
"gopkg.in/gin-gonic/gin.v1" | ||
) | ||
|
||
func createMyRender() multitemplate.Render { | ||
r := multitemplate.New() | ||
r.AddFromFiles("index", "templates/base.html", "templates/base.html") | ||
r.AddFromFiles("article", "templates/base.html", "templates/article.html") | ||
// r.AddFromFiles("login", "base.html", "login.html") | ||
// r.AddFromFiles("dashboard", "base.html", "dashboard.html") | ||
|
||
return r | ||
} | ||
|
||
func main() { | ||
router := gin.Default() | ||
router.HTMLRender = createMyRender() | ||
router.GET("/", func(c *gin.Context) { | ||
c.HTML(200, "index", gin.H{ | ||
"title": "Html5 Template Engine", | ||
}) | ||
}) | ||
router.GET("/article", func(c *gin.Context) { | ||
c.HTML(200, "index", gin.H{ | ||
"title": "Html5 Article Engine", | ||
}) | ||
}) | ||
router.Run(":8080") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<html class="no-js" lang=""> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>{{ .title }}</title> | ||
<meta name="description" content="Html5 Template Engine"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="favicon.ico" rel="icon" type="image/x-icon" /> | ||
<link rel="stylesheet" href="assets/css/main.css"> | ||
</head> | ||
<body> | ||
<h1 id="header">Welcome to {{ .title }}</h1> | ||
<h2>Features</h2> | ||
<ul> | ||
<li>The latest <a href="http://html5boilerplate.com/">html5boilerplate.com</a> source code.</li> | ||
<li>Includes <a href="https://github.com/appleboy/normalize.scss">Normalize.scss</a> v2.1.x and v1.1.x.</li> | ||
<li>The latest <a href="http://jquery.com">jQuery</a> and <a href="http://modernizr.com/">Modernizr</a> via <a href="http://bower.io/">Bower</a> package manager.</li> | ||
<li>Support <a href="http://coffeescript.org/">CoffeeScript</a>, <a href="http://requirejs.org/">RequireJS</a>, <a href="http://compass-style.org/">Compass</a>, html minification (via <a href="http://code.google.com/p/htmlcompressor/">htmlcompressor</a>).</li> | ||
<li>Support <a href="http://browsersync.io">browser-sync</a> Keep multiple browsers & devices in sync when building websites.</li> | ||
<li>Support JavaScript test framework <a href="http://visionmedia.github.io/mocha/">Mocha</a>.</li> | ||
<li>Support streaming build system <a href="http://gulpjs.com/">Gulp</a>.</li> | ||
<li>Support <a href="http://www.html5rocks.com/en/tutorials/developertools/devtools-terminal/">Terminal in Chrome Devtools</a>.</li> | ||
<li>Support minify PNG and JPEG images with <a href="https://github.com/sindresorhus/gulp-imagemin">image-min</a>.</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!doctype html> | ||
<html class="no-js" lang=""> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<title>{{ .title }}</title> | ||
<meta name="description" content="Html5 Template Engine"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="favicon.ico" rel="icon" type="image/x-icon" /> | ||
<link rel="stylesheet" href="assets/css/main.css"> | ||
</head> | ||
<body> | ||
<h1 id="header">Welcome to {{ .title }}</h1> | ||
<h2>Features</h2> | ||
<ul> | ||
<li>The latest <a href="http://html5boilerplate.com/">html5boilerplate.com</a> source code.</li> | ||
<li>Includes <a href="https://github.com/appleboy/normalize.scss">Normalize.scss</a> v2.1.x and v1.1.x.</li> | ||
<li>The latest <a href="http://jquery.com">jQuery</a> and <a href="http://modernizr.com/">Modernizr</a> via <a href="http://bower.io/">Bower</a> package manager.</li> | ||
<li>Support <a href="http://coffeescript.org/">CoffeeScript</a>, <a href="http://requirejs.org/">RequireJS</a>, <a href="http://compass-style.org/">Compass</a>, html minification (via <a href="http://code.google.com/p/htmlcompressor/">htmlcompressor</a>).</li> | ||
<li>Support <a href="http://browsersync.io">browser-sync</a> Keep multiple browsers & devices in sync when building websites.</li> | ||
<li>Support JavaScript test framework <a href="http://visionmedia.github.io/mocha/">Mocha</a>.</li> | ||
<li>Support streaming build system <a href="http://gulpjs.com/">Gulp</a>.</li> | ||
<li>Support <a href="http://www.html5rocks.com/en/tutorials/developertools/devtools-terminal/">Terminal in Chrome Devtools</a>.</li> | ||
<li>Support minify PNG and JPEG images with <a href="https://github.com/sindresorhus/gulp-imagemin">image-min</a>.</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters