update design build

This commit is contained in:
Eric Hulburd
2016-03-05 16:53:29 -06:00
parent 43a9daf94e
commit d7af1fc2b2
20 changed files with 172 additions and 149 deletions

View File

@@ -1,4 +1,4 @@
import rt from 'react-templates';
import react_templates from 'react-templates/dist/reactTemplates';
import React from 'react';
import _ from 'lodash';
@@ -8,33 +8,36 @@ var TEMPLATES = {};
class Templates {
static forComponent(name){
return TEMPLATES[name];
}
static sync(){
var all = [];
var all = [],
eval_context = {
'_': _,
'React': React
};
for (var component_name in COMPONENT_MAP){
var component = require('./../../' + COMPONENT_MAP[component_name] + '.component');
eval_context[component.NAME] = component;
}
for (var component_name in COMPONENT_MAP){
var done = new Promise((fnResolve, fnReject)=>{
Templates.evalTemplate(component_name, fnResolve);
Templates.evalTemplate(component_name, eval_context, fnResolve);
});
all.push(done);
}
return Promise.all(all);
}
static forComponent(name){
return TEMPLATES[name];
}
static evalTemplate(component_name, fnResolve){
static evalTemplate(component_name, eval_context, fnResolve){
jQuery.ajax({
url: COMPONENT_MAP[component_name] + '.rt'
}).done((template)=>{
var code = rt.convertTemplateToReact(template, {modules: 'none', name: component_name}),
eval_context = {};
code = code.replace('var ' + component_name + ' = ', 'eval_context.' + component_name + ' = ');
new Function('with(this){ ' + code + ' } ').call({
eval_context: eval_context,
'_': _,
'React': React
});
var code = react_templates.convertTemplateToReact(template, {modules: 'none', name: component_name}),
code = code.replace('var ' + component_name + ' = ', 'this.' + component_name + ' = ');
new Function('with(this){ ' + code + ' } ').call(eval_context);
TEMPLATES[component_name] = eval_context[component_name];
fnResolve();
});