Skip to content

Commit

Permalink
Merge pull request YahooArchive#365 from mridgway/hbdefault
Browse files Browse the repository at this point in the history
Made handlebars the default renderer for new projects and all examples
  • Loading branch information
mridgway committed Aug 9, 2012
2 parents 992b890 + d036c9d commit 3f7bb7f
Show file tree
Hide file tree
Showing 186 changed files with 32 additions and 34 deletions.
2 changes: 1 addition & 1 deletion examples/developer-guide/framed_config/README
Expand Up @@ -16,6 +16,6 @@ Relevant Files:
Modified Files:
./application.json
./routes.json
./mojits/MainMojit/views/index.mu.html
./mojits/MainMojit/views/index.hb.html
./mojits/MainMojit/controller.server.js

@@ -1,7 +1,7 @@
<div id="{{mojit_view_id}}" class="mojit">
<h2 style="color: #606; font-weight:bold;">Simple View</h2>
<div>type: {{type}}</div>
<div>time: {{#time}}{{hours}:{minutes}} {{period}}{{/time}}</div>
<div>time: {{#time}}{{hours}}:{{minutes}} {{period}}{{/time}}</div>
<div>show: {{#show}}{{type}}{{/show}}</div>
<div>hide: {{#hide}}{{type}}{{/hide}}</div>
<div>no show: {{^show}}{{type}}{{/show}}</div>
Expand Down
2 changes: 1 addition & 1 deletion source/lib/app/autoload/view-renderer.common.js
Expand Up @@ -20,7 +20,7 @@ YUI.add('mojito-view-renderer', function(Y) {
* @param {String} type view engine addon type to use
*/
function Renderer(type, viewId) {
type = type || 'mu';
type = type || 'hb';
this._renderer = new (Y.mojito.addons.viewEngines[type])(viewId);
}

Expand Down
22 changes: 10 additions & 12 deletions source/lib/management/utils.js
Expand Up @@ -10,7 +10,7 @@

var fs = require('fs'),
util = require('util'),
mu = require('../app/libs/Mulib/Mu'),
hb = require('yui/handlebars').Handlebars,
path = require('path'),
http = require('http'),
tty = require('tty'),
Expand Down Expand Up @@ -109,29 +109,27 @@ function process_template(archetype_path, file, mojit_dir, template) {
buffer = '',
stat,
tmpl,
compiled;
compiled,
output;

/* going to check for file size and use compileText to avoid
possible problems with any mustache templateRoot settings
possible problems with any handlebars templateRoot settings
*/
stat = fs.statSync(archetype_file);
if (stat.size > 0) {
tmpl = fs.readFileSync(archetype_file);
compiled = mu.compileText(tmpl);
compiled(template).addListener('data', function(c) {
buffer += c;
}).addListener('end', function() {
fs.writeFileSync(new_file, buffer);
});
tmpl = fs.readFileSync(archetype_file, 'utf8');
compiled = hb.compile(tmpl);
output = compiled(template);
fs.writeFileSync(new_file, output);
} else {
fs.writeFileSync(new_file, '');
}
}


function process_file(archetype_path, file, mojit_dir, template) {
if (/\.mu$/.test(file)) {
// Process as a Mu template
if (/\.hb$/.test(file)) {
// Process as a HB template
process_template(archetype_path, file, mojit_dir, template);
} else {
// Just copy the file over
Expand Down
Expand Up @@ -150,19 +150,19 @@ YUI.add('mojito-resource-store-adapter-tests', function(Y, NAME) {
});
},

'server mojit view index.mu.html is loaded correctly': function(){
'server mojit view index.hb.html is loaded correctly': function(){
var store = Y.mojito.ResourceStoreAdapter.init('server', resourceStore, dummyLog);
var instance = {type:'TestMojit3'};
store.expandInstance(instance, {}, function(err, instance){
A.areSame('index.mu.html', instance.views.index['content-path'].split('/').pop());
A.areSame('index.hb.html', instance.views.index['content-path'].split('/').pop());
});
},

'server mojit view index.iphone.mu.html is loaded correctly': function(){
'server mojit view index.iphone.hb.html is loaded correctly': function(){
var store = Y.mojito.ResourceStoreAdapter.init('server', resourceStore, dummyLog);
var instance = {type:'TestMojit3'};
store.expandInstance(instance, {device:'iphone'}, function(err, instance){
A.areSame('index.iphone.mu.html', instance.views.index['content-path'].split('/').pop());
A.areSame('index.iphone.hb.html', instance.views.index['content-path'].split('/').pop());
});
},

Expand Down
30 changes: 15 additions & 15 deletions source/lib/tests/autoload/store.server-tests.js
Expand Up @@ -164,19 +164,19 @@ YUI.add('mojito-store-server-tests', function(Y, NAME) {
A.areSame(3, Y.Object.keys(instance.views).length);

A.isObject(instance.views['test_1']);
A.areSame('/static/test_mojit_1/views/test_1.mu.html', instance.views['test_1']['content-path']);
A.areSame('mu', instance.views['test_1']['engine']);
A.areSame('/static/test_mojit_1/views/test_1.hb.html', instance.views['test_1']['content-path']);
A.areSame('hb', instance.views['test_1']['engine']);
A.areSame('/static/test_mojit_1/binders/test_1.js', instance.views['test_1']['binder-path']);
A.areSame('test_mojit_1Bindertest_1', instance.views['test_1']['binder-module']);
A.isNotUndefined(instance.views['test_1']['binder-yui-sorted']['mojito-client']);

A.isObject(instance.views['test_2']);
A.areSame('/static/test_mojit_1/views/test_2.mu.html', instance.views['test_2']['content-path']);
A.areSame('mu', instance.views['test_2']['engine']);
A.areSame('/static/test_mojit_1/views/test_2.hb.html', instance.views['test_2']['content-path']);
A.areSame('hb', instance.views['test_2']['engine']);

A.isObject(instance.views['subdir/test_1']);
A.areSame('/static/test_mojit_1/views/subdir/test_1.mu.html', instance.views['subdir/test_1']['content-path']);
A.areSame('mu', instance.views['subdir/test_1']['engine']);
A.areSame('/static/test_mojit_1/views/subdir/test_1.hb.html', instance.views['subdir/test_1']['content-path']);
A.areSame('hb', instance.views['subdir/test_1']['engine']);
A.areSame('/static/test_mojit_1/binders/subdir/test_1.js', instance.views['subdir/test_1']['binder-path']);
A.areSame('test_mojit_1Bindersubdir/test_1', instance.views['subdir/test_1']['binder-module']);
A.isNotUndefined(instance.views['subdir/test_1']['binder-yui-sorted']['mojito-client']);
Expand Down Expand Up @@ -223,17 +223,17 @@ YUI.add('mojito-store-server-tests', function(Y, NAME) {
A.isUndefined(urls['/static/TestMojit5/package.json']);
},

'server mojit view index.mu.html is loaded correctly': function() {
'server mojit view index.hb.html is loaded correctly': function() {
var instance = {type:'TestMojit3'};
store.expandInstance(instance, {}, function(err, instance){
A.areSame('index.mu.html', instance.views.index['content-path'].split('/').pop());
A.areSame('index.hb.html', instance.views.index['content-path'].split('/').pop());
});
},

'server mojit view index.iphone.mu.html is loaded correctly': function(){
'server mojit view index.iphone.hb.html is loaded correctly': function(){
var instance = {type:'TestMojit3'};
store.expandInstance(instance, {device:'iphone'}, function(err, instance){
A.areSame('index.iphone.mu.html', instance.views.index['content-path'].split('/').pop());
A.areSame('index.iphone.hb.html', instance.views.index['content-path'].split('/').pop());
});
},

Expand Down Expand Up @@ -400,9 +400,9 @@ YUI.add('mojito-store-server-tests', function(Y, NAME) {
var spec = { type: 'PagedFlickr' };
var ctx = { device: 'iphone' };
store.expandInstance(spec, ctx, function(err, instance) {
A.areSame(libpath.join(fixtures, 'mojits/PagedFlickr/views/index.iphone.mu.html'), instance.views.index['content-path']);
A.areSame(libpath.join(fixtures, 'mojits/PagedFlickr/views/index.iphone.hb.html'), instance.views.index['content-path']);
});
},
}

}));

Expand Down Expand Up @@ -748,14 +748,14 @@ YUI.add('mojito-store-server-tests', function(Y, NAME) {
A.areSame('view', res.type);
A.areSame('x', res.name);
A.areSame('html', res.view.outputFormat);
A.areSame('mu', res.view.engine);
A.areSame('hb', res.view.engine);
switch (res.source.fs.basename) {
case 'x.mu':
case 'x.hb':
A.areSame('*', res.selector);
A.areSame('common', res.affinity);
A.areSame('.html', res.source.fs.ext);
break;
case 'x.iphone.mu':
case 'x.iphone.hb':
A.areSame('iphone', res.selector);
A.areSame('common', res.affinity);
A.areSame('.html', res.source.fs.ext);
Expand Down

0 comments on commit 3f7bb7f

Please sign in to comment.