allow jammit to serve up our handlebars templates, making them cacheable! added bonus: changing a handlebars template now doesn't involve re-running rspec to regenerate them. zing.
This commit is contained in:
parent
d1fbf7b55c
commit
39ff47150b
13 changed files with 31 additions and 8 deletions
|
|
@ -3,9 +3,3 @@
|
|||
- template_name = File.basename(template, ".jst").gsub("_","-")
|
||||
%script{:id => "#{template_name}-template", :type => 'text/template'}
|
||||
!= File.read(templates_dir.join(template))
|
||||
|
||||
- #don't tell my mom I did this, okay?
|
||||
- Dir[templates_dir.to_s + "/*.handlebars"].each do |template|
|
||||
- template_name = File.basename(template, ".handlebars").gsub("_","-")
|
||||
%script{:id => "#{template_name}-template", :type => 'text/template'}
|
||||
!= File.read(templates_dir.join(template))
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@
|
|||
|
||||
= jquery_include_tag
|
||||
- unless @landing_page
|
||||
= include_javascripts :main
|
||||
= include_javascripts :main, :templates
|
||||
|
||||
:javascript
|
||||
Diaspora.I18n.loadLocale(#{get_javascript_strings_for(I18n.locale).to_json}, "#{I18n.locale}");
|
||||
Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}";
|
||||
|
|
|
|||
|
|
@ -2,9 +2,17 @@ package_assets: on
|
|||
embed_assets: datauri
|
||||
compress_assets: on
|
||||
gzip_assets: off
|
||||
|
||||
template_function: off
|
||||
template_extension: 'handlebars'
|
||||
|
||||
javascripts:
|
||||
jquery:
|
||||
- public/javascripts/vendor/jquery-1.7.1.min.js
|
||||
|
||||
templates:
|
||||
- public/javascripts/app/templates/*.handlebars
|
||||
|
||||
main:
|
||||
- public/javascripts/vendor/underscore.js
|
||||
- public/javascripts/vendor/backbone.js
|
||||
|
|
|
|||
7
config/assets_test.yml
Normal file
7
config/assets_test.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package_assets: on
|
||||
template_function: off
|
||||
template_extension: 'handlebars'
|
||||
|
||||
javascripts:
|
||||
app:
|
||||
- public/javascripts/app/templates/*
|
||||
|
|
@ -30,7 +30,7 @@ app.views.Base = Backbone.View.extend({
|
|||
this.template = _.template(templateHTML);
|
||||
} else {
|
||||
window.templateCache = window.templateCache || {}
|
||||
templateHTML = $("#" + this.templateName + "-template").html(); //don't forget to regenerate your jasmine fixtures ;-)
|
||||
templateHTML = JST[this.templateName];
|
||||
this.template = templateCache[this.templateName] = templateCache[this.templateName] || Handlebars.compile(templateHTML);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
# - dist/**/*.js
|
||||
#
|
||||
src_files:
|
||||
# load up our outputted templates, bound to window.JST
|
||||
- public/assets/app.js
|
||||
|
||||
- public/javascripts/vendor/underscore.js
|
||||
- public/javascripts/vendor/jquery-1.7.1.min.js
|
||||
- public/javascripts/vendor/jquery-ui-1.8.9.custom.min.js
|
||||
|
|
@ -59,6 +62,7 @@ src_files:
|
|||
- public/javascripts/aspects-dropdown.js
|
||||
- public/javascripts/content-updater.js
|
||||
- public/javascripts/tag-followings.js
|
||||
|
||||
# stylesheets
|
||||
#
|
||||
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
||||
|
|
|
|||
9
spec/javascripts/support/jasmine_config.rb
Normal file
9
spec/javascripts/support/jasmine_config.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
require 'jammit'
|
||||
module Jasmine
|
||||
class Config
|
||||
|
||||
Jammit.reload!
|
||||
Jammit.package!({ :config_path => Rails.root.join("config", "assets_test.yml")})
|
||||
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue