slimmer 3.22.1 → 3.23.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -7
- data/lib/slimmer/template.rb +6 -1
- data/lib/slimmer/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -2,8 +2,8 @@ Slimmer provides rack middleware for applying a standard header and footer aroun
|
|
2
2
|
returned by a ruby (rack) application.
|
3
3
|
|
4
4
|
It does this by taking the page rendered by the application, extracting the contents of
|
5
|
-
a div with id 'wrapper' and inserting that into one of its templates.
|
6
|
-
various other details, such as meta, script, and style tags.
|
5
|
+
a div with id 'wrapper' and inserting that into a div with the same id in one of its templates.
|
6
|
+
It also transfers various other details, such as meta, script, and style tags.
|
7
7
|
|
8
8
|
## Use in a Rails app
|
9
9
|
|
@@ -29,25 +29,33 @@ or
|
|
29
29
|
|
30
30
|
use Slimmer::App, :asset_host => "http://my.alternative.host"
|
31
31
|
|
32
|
+
## Asset tag helpers
|
33
|
+
|
34
|
+
To get asset tag helpers to point to your external asset server, add
|
35
|
+
|
36
|
+
config.action_controller.asset_host = "http://my.alternative.host"
|
37
|
+
|
38
|
+
to application.rb.
|
39
|
+
|
32
40
|
## Specifying a template
|
33
41
|
|
34
|
-
A specific template can be requested by giving its name in the X-Slimmer-Template HTTP header
|
42
|
+
A specific template can be requested by giving its name in the X-Slimmer-Template HTTP header.
|
35
43
|
|
36
|
-
|
44
|
+
In a controller action, you can do this by calling `slimmer_template`.
|
37
45
|
|
38
46
|
class MyController < ApplicationController
|
39
47
|
def index
|
40
|
-
|
48
|
+
slimmer_template 'homepage'
|
41
49
|
end
|
42
50
|
end
|
43
51
|
|
44
|
-
There's also a macro style method:
|
52
|
+
There's also a macro style method which will affect all actions:
|
45
53
|
|
46
54
|
class YourController < ApplicationController
|
47
55
|
slimmer_template :admin
|
48
56
|
end
|
49
57
|
|
50
|
-
To get this, include Slimmer::Template in your
|
58
|
+
To get this, include Slimmer::Template in your ApplicationController:
|
51
59
|
|
52
60
|
class ApplicationController < ActionController::Base
|
53
61
|
include Slimmer::Template
|
data/lib/slimmer/template.rb
CHANGED
@@ -4,10 +4,15 @@ module Slimmer
|
|
4
4
|
into.extend ClassMethods
|
5
5
|
end
|
6
6
|
|
7
|
+
def slimmer_template template_name
|
8
|
+
response.headers[Slimmer::Headers::TEMPLATE_HEADER] = template_name.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
|
7
12
|
module ClassMethods
|
8
13
|
def slimmer_template template_name
|
9
14
|
after_filter do
|
10
|
-
response.headers[Slimmer::Headers::TEMPLATE_HEADER]
|
15
|
+
response.headers[Slimmer::Headers::TEMPLATE_HEADER] ||= template_name.to_s
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
data/lib/slimmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.23.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-11-
|
13
|
+
date: 2013-11-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -322,7 +322,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
322
322
|
version: '0'
|
323
323
|
segments:
|
324
324
|
- 0
|
325
|
-
hash: -
|
325
|
+
hash: -4371184538840629233
|
326
326
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
327
327
|
none: false
|
328
328
|
requirements:
|
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
331
331
|
version: '0'
|
332
332
|
segments:
|
333
333
|
- 0
|
334
|
-
hash: -
|
334
|
+
hash: -4371184538840629233
|
335
335
|
requirements: []
|
336
336
|
rubyforge_project: slimmer
|
337
337
|
rubygems_version: 1.8.23
|