Skip to content

Commit a60101f

Browse files
committed
Adds support for adding arbitrary js libraries to HTML head
1 parent 3120bda commit a60101f

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ You'll want to copy `app/views/layouts/_site_nav.html.erb` into your local repo
3838

3939
If you need to make changes to other templates, you can also copy those to your local repo but you should check with others as the main header / footer / etc are probably best left as they are in this gem.
4040

41+
## Adding Additional JavaScript to HTML Head
42+
43+
You can load additional js to individual pages using:
44+
45+
```
46+
<% content_for :additional_js do %>
47+
<script>alert("hi");</script>
48+
<% end %>
49+
```
50+
51+
This can appear as many times as you need on as many templates as you need. If
52+
called multiple times the results are concatenated. This is intended primarily
53+
for adding external support libraries. For JS you are writing, include via
54+
`application.scss` as normal.
55+
4156
## Development
4257

4358
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

app/views/layouts/_head.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
<%= render partial: "layouts/js_exception_handler" %>
2020
<%= javascript_include_tag "application" %>
21+
22+
<%= yield :additional_js %>
23+
2124
<% if (ENV['GOOGLE_ANALYTICS']) %>
2225
<script type="text/javascript">
2326
// Google Analytics

0 commit comments

Comments
 (0)