Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add template.renderSync #5

Merged
merged 1 commit into from

2 participants

@mcculloughsean

No description provided.

@quackingduck quackingduck merged commit 2542915 into quackingduck-archive:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 9, 2012
  1. Add template.renderSync

    Sean McCullough authored
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 0 deletions.
  1. +8 −0 lib/bulk_hogan.js
  2. +6 −0 src/bulk_hogan.coffee
View
8 lib/bulk_hogan.js
@@ -28,6 +28,14 @@
});
};
+ templates.renderSync = function(name, view) {
+ var compiledTemplate;
+ if (this.cache == null) throw new Error('Template files have not been loaded');
+ compiledTemplate = this.cache[name];
+ if (compiledTemplate == null) throw new Error("No template named: " + name);
+ return compiledTemplate.render(view, this.cache);
+ };
+
templates.load = function(cb) {
var _this = this;
if (this.cache != null) return cb(noErr, this.cache);
View
6 src/bulk_hogan.coffee
@@ -54,6 +54,12 @@ templates.render = (name, view, cb) ->
catch err
cb err
+templates.renderSync = (name, view) ->
+ throw new Error 'Template files have not been loaded' unless @cache?
+ compiledTemplate = @cache[name]
+ throw new Error "No template named: #{name}" unless compiledTemplate?
+ compiledTemplate.render view, @cache
+
templates.load = (cb) ->
return cb(noErr, @cache) if @cache?
async.parallel
Something went wrong with that request. Please try again.