Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove hard-coded URLs from templates client-side code.
Closes #13
- Loading branch information
Showing
10 changed files
with
70 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
var exphbs = require('express3-handlebars'), | ||
Y = require('yui').use('handlebars'), | ||
Y = require('yui').use('handlebars', 'pnm-helpers'), | ||
|
||
config = require('../conf/config'); | ||
|
||
module.exports = exphbs.create({ | ||
defaultLayout: config.layouts.main, | ||
handlebars : Y.Handlebars, | ||
helpers : Y.PNM.Helpers, | ||
partialsDir : config.dirs.templates | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
YUI.add('pnm-helpers', function (Y) { | ||
|
||
var PNM_ENV = YUI.namespace('Env.PNM'); | ||
|
||
regexPathParam = /([:*])([\w\-]+)?/g; | ||
|
||
Y.namespace('PNM').Helpers = { | ||
pathTo: function (routeName, context) { | ||
context || (context = this); | ||
|
||
var route = PNM_ENV.ROUTES[routeName], | ||
path, keys; | ||
|
||
if (!route) { return ''; } | ||
|
||
path = route.path; | ||
keys = Y.Array.map(route.keys, function (key) { return key.name; }); | ||
|
||
if (context && keys.length) { | ||
if (context._isYUIModel) { | ||
context = context.getAttrs(keys); | ||
} | ||
|
||
Y.Array.each(keys, function (key) { | ||
var regex = new RegExp('[:*]' + key + '\\b'); | ||
path = path.replace(regex, context[key]); | ||
}); | ||
} | ||
|
||
// Replace missing params with empty strings. | ||
return path.replace(regexPathParam, ''); | ||
} | ||
}; | ||
|
||
}, '0.6.0', { | ||
requires: [ | ||
'array-extras' | ||
] | ||
}); |
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