Skip to content

Commit

Permalink
chore(plan): plan tests, linting
Browse files Browse the repository at this point in the history
  • Loading branch information
thepian committed Mar 25, 2015
1 parent be857ae commit 4f9cb6a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
18 changes: 9 additions & 9 deletions lib/client/template_engine.js
Expand Up @@ -9,7 +9,7 @@

require('colors');

var pathlib = require('path'),
var path = require('path'),
formatters = require('./formatters'),
client = require('./system'),
log = require('../utils/log');
Expand All @@ -19,7 +19,7 @@ module.exports = function(ss,options) {
var mods = [];

// Set the Default Engine - simply wraps each template in a <script> tag
var defaultEngine = require('./template_engines/default').init(ss.root,null,options);
var defaultEngine = require('./template_engines/default')(ss.root,null,options);

return {

Expand Down Expand Up @@ -65,7 +65,7 @@ module.exports = function(ss,options) {
dirs = [dirs];
}

var templatesPrefix = pathlib.relative(options.dirs.client,options.dirs.templates);
var templatesPrefix = path.relative(options.dirs.client,options.dirs.templates);
dirs = dirs.map(function(dir) {
if (dir === '/') {
return '.';
Expand Down Expand Up @@ -175,7 +175,7 @@ module.exports = function(ss,options) {

// prviate

function wrapTemplate(template, path, logicPath, engine, prevEngine) {
function wrapTemplate(template, pth, logicPath, engine, prevEngine) {
var output;
output = [];

Expand All @@ -191,7 +191,7 @@ function wrapTemplate(template, path, logicPath, engine, prevEngine) {

// Add main template output and return
prevEngine = engine;
output.push(engine.process(template.toString(), logicPath, suggestedId(path)));
output.push(engine.process(template.toString(), logicPath, suggestedId(pth)));
return output.join('');
}

Expand All @@ -210,11 +210,11 @@ function selectEngine(templateEngines, pathAry) {
// This should be on the bundler entries, so it can be tweaked by bundler before being used by the engine
// Suggest an ID for this template based upon its path
// 3rd party Template Engine modules are free to use their own naming conventions but we recommend using this where possible
function suggestedId(path) {
path = path.replace(/^\.\//,'');
function suggestedId(pth) {
pth = pth.replace(/^\.\//,'');
var sp;
sp = path.split('.');
if (path.indexOf('.') > 0) {
sp = pth.split('.');
if (pth.indexOf('.') > 0) {
sp.pop();
}
return sp.join('.').replace(/\//g, '-');
Expand Down
2 changes: 1 addition & 1 deletion lib/client/template_engines/angular.js
Expand Up @@ -3,7 +3,7 @@

'use strict';

exports.init = function(root, config) {
exports.init = function() {
return {
name: 'Angular.js',
process: function(template, path, id) {
Expand Down
2 changes: 1 addition & 1 deletion lib/client/template_engines/default.js
Expand Up @@ -3,7 +3,7 @@
// Note all templates are prefixed with 'tmpl-' to prevent conflicts with DOM IDs in your application
'use strict';

exports.init = function(root, config) {
module.exports = function() {
return {
name: 'Default',
process: function(template, path, id) {
Expand Down
2 changes: 1 addition & 1 deletion lib/client/template_engines/ember.js
Expand Up @@ -2,7 +2,7 @@
// Note Ember compiles these Handlebars templates one time only when you call Em.Application.create();
'use strict';

exports.init = function(root, config) {
exports.init = function() {
return {
name: 'Ember.js',
process: function(template, path, id) {
Expand Down
3 changes: 3 additions & 0 deletions test/unit/client/formatters.test.js
Expand Up @@ -9,7 +9,10 @@ var path = require('path'),

describe('code formatter loading API', function () {

describe('ss api', function() {

it('should throw exception when called as function');
});

describe('#add', function () {

Expand Down
8 changes: 8 additions & 0 deletions test/unit/client/template_engine.test.js
Expand Up @@ -136,6 +136,7 @@ describe('Template engine', function() {
});
});

it('should wrap with old API custom engine selectFormatter function');
/*TODO
it('should wrap with old API custom engine selectFormatter function', function(done) {
Expand All @@ -161,5 +162,12 @@ describe('Template engine', function() {
});
*/

it('should append suffix');

it('should prepend prefix');

it('should catch and pass error object');

it('should suggest good default IDs');
});
});

0 comments on commit 4f9cb6a

Please sign in to comment.