diff --git a/Gemfile b/Gemfile index 9f348605e..213b31301 100644 --- a/Gemfile +++ b/Gemfile @@ -81,6 +81,7 @@ gem 'handlebars_assets', '0.18.0' gem 'jquery-rails', '3.1.2' gem 'rails-assets-jquery', '1.11.1' # Should be kept in sync with jquery-rails gem 'js_image_paths', '0.0.1' +gem 'js-routes', '0.9.9' # jQuery plugins diff --git a/Gemfile.lock b/Gemfile.lock index 483a6fc24..b13a4a6d0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -238,6 +238,9 @@ GEM thor (>= 0.14, < 2.0) jquery-ui-rails (4.2.1) railties (>= 3.2.16) + js-routes (0.9.9) + railties (>= 3.2) + sprockets-rails js_image_paths (0.0.1) rails (~> 4.0) json (1.8.1) @@ -533,6 +536,7 @@ DEPENDENCIES jasmine (= 2.0.2) jasmine-jquery-rails (= 2.0.3) jquery-rails (= 3.1.2) + js-routes (= 0.9.9) js_image_paths (= 0.0.1) json (= 1.8.1) markerb (= 1.0.2) diff --git a/app/assets/javascripts/app/helpers/handlebars-helpers.js b/app/assets/javascripts/app/helpers/handlebars-helpers.js index fd8bd0657..ebb1e132b 100644 --- a/app/assets/javascripts/app/helpers/handlebars-helpers.js +++ b/app/assets/javascripts/app/helpers/handlebars-helpers.js @@ -6,6 +6,15 @@ Handlebars.registerHelper('imageUrl', function(path){ return ImagePaths.get(path); }); +Handlebars.registerHelper('urlTo', function(path_helper, id, data){ + if( !data ) { + // only one argument given to helper, mangle parameters + data = id; + return Routes[path_helper+'_path'](data.hash); + } + return Routes[path_helper+'_path'](id, data.hash); +}); + Handlebars.registerHelper('linkToPerson', function(context, block) { if( !context ) context = this; var html = "{{t 'people.edit_my_profile'}} - {{/if}} - {{#if is_blocked}} + {{t 'people.edit_my_profile'}} + {{else}} {{#if is_blocked}} {{t 'people.stop_ignoring'}} {{else}}
- {{/if}} + {{/if}}{{/if}} {{/if}} @@ -17,6 +16,10 @@ {{diaspora_id}}