README.md in rack-scriptstacker-0.0.1 vs README.md in rack-scriptstacker-0.1.0
- old
+ new
@@ -2,23 +2,23 @@
Painless static file handling for Rack apps.
- Automatically configures `Rack::Static` by default.
- Glob and inject JavaScript/CSS files into served HTML.
+ - Inserts CSS before `</head>` and JS before `</body>` by default.
+ - Change the inject mode to use placeholder slots instead.
# Usage
```html
<!-- index.html //-->
<!doctype html>
<html lang="en">
<head>
- <!-- ScriptStacker: CSS //-->
</head>
<body>
- <!-- ScriptStacker: JAVASCRIPT //-->
</body>
</html>
```
and
@@ -30,11 +30,11 @@
class App
def call env
[
200,
- { 'Content-Type' => 'text/html' },
+ {'Content-Type' => 'text/html'},
[File.read('index.html')]
]
end
end
@@ -96,8 +96,29 @@
```ruby
use Rack::ScriptStacker,
stackers: {
javascript: { template: '<script src="%s"></script>' }
} do
+ javascript 'static/javascript'
+end
+```
+
+## Use placeholder slots
+
+```html
+<!-- index.html //-->
+
+<!doctype html>
+<html lang="en">
+ <head>
+ <!-- ScriptStacker: CSS //-->
+ </head>
+ <body>
+ <!-- ScriptStacker: JAVASCRIPT //-->
+ </body>
+</html>
+
+use Rack::ScriptStacker, inject_mode: :slot do
+ css 'static/css'
javascript 'static/javascript'
end
```