ocean-themes
v0.1.4
Published
Organize Express views into themes
Readme
Adds theme support for Express views. You can either pass in your themes directory or use the default directory. Essentially wraps an Express app.
##Installation
npm install ocean-themes
##Usage
Stand-alone
var OceanThemes = require('ocean-themes');
var themes = new OceanThemes()
var app = themes.app
themes.activateTheme('default')
//other default themes from bootswatch.com
//more to come
//themes.activateTheme('flatly')
//themes.activateTheme('superhero')
app.get('/', function(req, res, next){
res.theme('index', {
page: "Page name"
})
})
//switch theme
app.get('/theme/:name', function(req, res, next){
themes.activateTheme(req.params.name);
res.redirect('/');
})
themes.listen()
Or pass in an Express App
var app = express();
var themes = new OceanThemes(app)
//routes
app.listen(3000)
Or mount an Express app
var app = express();
var themes = new OceanThemes()
//routes
app.get()
themes.mount(app)
themes.listen()
OceanThemes must be instantiated before any routes that plan on using res.theme(). Like any other middleware, order matters.
##Themes All themes must have a config.json. When the theme is activated, the express.static will point to the theme directory. So each theme can have it's own js, css, images, ect folders.
##config.json
specify the name and templating engine
{
"name": "theme name",
"engine": "jade",
"ext": "jade"
}