Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Allow defining functions in requirejs.yml #179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/helpers/requirejs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ def requirejs_include_tag(name=nil, &block)
end

run_config['baseUrl'] = base_url(name)
# Detect functions in JSON and unescape them so they can be evaluated by RequireJS
run_config_json = run_config.to_json.gsub(/"(function\(.*?\)\s*?{.*?}[\s\\n]*)"/) do |f|
eval(f).strip.delete("\n")
end
html.concat <<-HTML
<script>var require = #{run_config.to_json};</script>
<script>var require = #{run_config_json};</script>
HTML
end

Expand Down