Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make oc-client.js supporting more templates via an extendable API #396

Merged
merged 2 commits into from
Mar 19, 2017

Conversation

nickbalestra
Copy link
Contributor

@nickbalestra nickbalestra commented Mar 8, 2017

Make oc-client.js supporting more templates other then jade and handlebars (oc-template-react,..) through an API that allows to extend such support.


Context: The Api need to be able to register the new type of template supported and its various requirements (dependecies,..) Internally the architecture should take care of hadnling all the aspects needed in order to be able to render the new type of components (i.e: oc-template-react).

pre-configuration API:

<script>var oc = { conf: { templates: [] }};</script>
<script src="//registry.components.com/oc-client/client.js"></script>

post-configuration API:

<script src="//registry.components.com/oc-client/client.js"></script>
<script>oc.registerTemplates()</script> 
  • Render after a new template has been registered

@@ -294,25 +310,35 @@ var oc = oc || {};

oc.render = function(compiledViewInfo, model, callback){
oc.ready(function(){
if(!!compiledViewInfo.type.match(/jade|handlebars/g)){

var template = templates.find(function(template){return template.type === compiledViewInfo.type});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find is not supported in IE: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find
Perhaps we can use something available in jQuery?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go vanilla, no need for a $ dependency just for that in here imho.

@matteofigus
Copy link
Member

This is fantastic, thanks @nickbalestra

@matteofigus matteofigus merged commit 88989ce into master Mar 19, 2017
@matteofigus matteofigus deleted the oclient-templates branch March 19, 2017 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants