diff options
Diffstat (limited to 'src/templateRenderer.js')
-rw-r--r-- | src/templateRenderer.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/templateRenderer.js b/src/templateRenderer.js new file mode 100644 index 0000000..acd6289 --- /dev/null +++ b/src/templateRenderer.js @@ -0,0 +1,24 @@ +define(['nunjucks'], function(nunjucks) { + + var TEMPLATE_RENDERER = { + /* + * target: target HTML element can be an #id or .class. + * partialUrl : the url where specified partial exists. + * data : JSON object contains the data to be rendered. + * callback : The callback method that will be executed when + * template is successfull loaded + */ + render: function(target, partialUrl, data, callback) { + require(['text!' + partialUrl], function(template) { + var rendered = nunjucks.renderString(template, data); + $(target).html(rendered); + callback.call(); + }); + + + } + } + + return TEMPLATE_RENDERER; + +}); |