This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Marko template engine support. Closes #75
- Loading branch information
Showing
22 changed files
with
200 additions
and
67 deletions.
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
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
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
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
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
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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
express = require 'express' | ||
router = express.Router() | ||
router = express.Router()<% if(options.viewEngine == 'marko'){ %> | ||
marko = require 'marko'<% } %> | ||
|
||
# GET home page. | ||
router.get '/', (req, res) -> | ||
res.render 'index', { title: 'Express' } | ||
<% if(options.viewEngine == 'marko'){ %> | ||
indexTemplate = marko.load require.resolve '../views/index.marko'<% } %> | ||
router.get '/', (req, res) -><% if(options.viewEngine == 'marko'){ %> | ||
indexTemplate.render | ||
title: 'Express' | ||
, res<% } else { %> | ||
res.render 'index', { title: 'Express' }<% } %> | ||
|
||
module.exports = router |
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
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
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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
var express = require('express'); | ||
var router = express.Router(); | ||
var router = express.Router();<% if(options.viewEngine == 'marko'){ %> | ||
var marko = require('marko');<% } %> | ||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res) { | ||
res.render('index', { title: 'Express' }); | ||
<% if(options.viewEngine == 'marko'){ %> | ||
var indexTemplate = marko.load(require.resolve('../views/index.marko'));<% } %> | ||
router.get('/', function(req, res) {<% if(options.viewEngine == 'marko'){ %> | ||
indexTemplate.render({ | ||
title: 'Express' | ||
}, res);<% } else { %> | ||
res.render('index', { title: 'Express' });<% } %> | ||
}); | ||
|
||
module.exports = router; |
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 |
---|---|---|
@@ -1,17 +1,23 @@ | ||
express = require 'express' | ||
router = express.Router()<% if(options.database == 'mongodb'){ %> | ||
router = express.Router()<% if(options.viewEngine == 'marko'){ %> | ||
marko = require 'marko'<% } %><% if(options.database == 'mongodb'){ %> | ||
mongoose = require 'mongoose' | ||
Article = mongoose.model 'Article'<% } %><% if(options.database == 'mysql' || options.database == 'postgresql'){ %> | ||
db = require '../models'<% } %> | ||
|
||
module.exports = (app) -> | ||
app.use '/', router | ||
|
||
<% if(options.viewEngine == 'marko'){ %> | ||
indexTemplate = marko.load require.resolve '../views/index.marko'<% } %> | ||
router.get '/', (req, res, next) -> | ||
<% if(options.database == 'mongodb'){ %> | ||
Article.find (err, articles) -> | ||
return next(err) if err<% } %><% if(options.database == 'mysql' || options.database == 'postgresql'){ %> | ||
db.Article.findAll().success (articles) -><% } %> | ||
db.Article.findAll().success (articles) -><% } %><% if(options.viewEngine == 'marko'){ %> | ||
indexTemplate.render | ||
title: 'Generator-Express MVC', | ||
articles: articles | ||
, res<% } else { %> | ||
res.render 'index', | ||
title: 'Generator-Express MVC' | ||
articles: articles | ||
articles: articles<% } %> |
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
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
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
Oops, something went wrong.