Skip to content

Commit 0f9dd16

Browse files
committed
Fix Javascript to work with new Haml 5.0 escape behavior
The interpolated Ruby in a Haml :javascript filter now gets HTML escaped, breaking the way it was being used in the shared _head template to pass the set of valid languages and projects. The fix is to pass it as an HTML dataset instead, and pull that into the Javascript afterwards. I followed the example of railsadminteam/rails_admin#2870
1 parent 896ce96 commit 0f9dd16

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

app/views/shared/_head.html.haml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
= javascript_include_tag '/assets/javascripts/i18n'
1313
= javascript_include_tag '/assets/javascripts/i18n/' + I18n.locale.to_s
14+
#wikis{:'data-projects' => Wiki::PROJECTS.to_json, :'data-languages' => Wiki::LANGUAGES.to_json}
1415
:javascript
1516
I18n.defaultLocale = "#{I18n.default_locale}";
1617
I18n.locale = "#{I18n.locale}";
@@ -27,8 +28,8 @@
2728
disableTraining: #{Features.disable_training?}
2829
}
2930

30-
WikiProjects = #{Wiki::PROJECTS}
31-
WikiLanguages = #{Wiki::LANGUAGES}
31+
WikiProjects = document.getElementById("wikis").dataset.projects
32+
WikiLanguages = document.getElementById("wikis").dataset.languages
3233

3334
SentryDsn = "#{ENV['sentry_public_dsn']}"
3435
SalesforceServer = "#{ENV['SF_SERVER']}"

0 commit comments

Comments
 (0)