Skip to content

Instantly share code, notes, and snippets.

@scottelundgren
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottelundgren/a794411559f334383a4a to your computer and use it in GitHub Desktop.
Save scottelundgren/a794411559f334383a4a to your computer and use it in GitHub Desktop.
auto_javascript_include_tag fails when directory_indexes is active
middleman init example.com
cd source
cp index.html.erb example.html.erb
edit example.html.erb to
---
title: Example Page
---
<h1>Example Page</h1>
<p>Hello, world!</p>
echo 'alert("Here is an alert.");' > /javascripts/example.js
edit javascripts/all.js
delete the line "//= require_tree .”
This keeps middleman from walking the /javascripts directory and compiling our test into one all.js file
edit layouts/layout.erb
add <%= auto_javascript_include_tag %>, before </head>, about line 14
edit ../config.rb
remove the comment on line 40, enabling " activate :livereload”
middleman server
visit http://localhost:4567/
The default page only should display. No javascript should display.
visit http://localhost:4567/example.html
An alert should display with the example page
edit ../config.rb
add activate :directory_indexes
visit http://localhost:4567/example/
The alert will not display. Check the page source, example.js is not included.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment