Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding helpers to basic express example

  • Loading branch information...
commit 2f38388819eb8087d1c8482b4e710a212c25574d 1 parent bb46204
Paul Serby authored
27 examples/express/app.js
View
@@ -6,23 +6,30 @@ var
app.version = '0.1';
-// Define a custom compile so version can be got from inside the .styl
-function stylusCompile(str, path) {
- return stylus(str)
- .set('filename', path)
- .set('warn', true)
- .set('compress', true)
- .define('version', function() { return app.version; });
-}
-
// Configuration
app.configure(function(){
+
+ var basic = versionator.createBasic('v' + app.version);
+
+ app.helpers({
+ versionPath: basic.versionPath
+ });
+
+ // Define a custom compile so version can be got from inside the .styl
+ function stylusCompile(str, path) {
+ return stylus(str)
+ .set('filename', path)
+ .set('warn', true)
+ .set('compress', true)
+ .define('versionPath', basic.versionPath);
+ }
+
app
.set('views', __dirname + '/views')
.set('view engine', 'jade')
.use(express.bodyParser())
.use(express.methodOverride())
- .use(versionator.createBasic('v' + app.version).middleware)
+ .use(basic.middleware)
.use(stylus.middleware({
src: __dirname + '/public/',
compile: stylusCompile }))
2  examples/express/public/css/style.styl
View
@@ -7,4 +7,4 @@ a
#break
width 100%
height 10px
- background-image: url('/images/v' + version() + '/background.png')
+ background-image: url(versionPath('/images/background.png'))
2  examples/express/views/index.jade
View
@@ -4,4 +4,4 @@ append body
div#break
append scripts
- script(src='/js/v#{app.version}/example.js')
+ script(src=versionPath('/js/example.js'))
2  examples/express/views/layout.jade
View
@@ -2,7 +2,7 @@
html
head
title= title
- link(rel='stylesheet', href='/css/v#{app.version}/style.css')
+ link(rel='stylesheet', href=versionPath('/css/style.css'))
body
block body
h1 Versionator Example
Please sign in to comment.
Something went wrong with that request. Please try again.