sinatra-thymeleaf 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/lib/sinatra/thymeleaf.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4461236a061f630e5612a026f75fc9deeaba26c9
|
4
|
+
data.tar.gz: 39676324aa51a7d607fe3ab750dc13c9716e82be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e498d48013b67e0034738e3b0e24a3405ac132acda3f6438442e5761d5c2c48d0d6c3dbfefd836c7f231646c5362c9f1ed65b5e067f5ce4f7def3cd213fb715
|
7
|
+
data.tar.gz: abbf89f9939f6c7f991162e36c2483f4f7b69cd2d7e61087a2b0f0263e23dcd961b1e0ea665004f4a5a4e58859459b26f2d4758726d55211cbfcd49bd85e40f7
|
data/README.md
CHANGED
@@ -53,4 +53,25 @@ You can use i18n localization in your templates, like this:
|
|
53
53
|
```
|
54
54
|
This works by using I18n.t directly so remember to configure i18n for your sinatra app
|
55
55
|
|
56
|
+
#Flash support
|
57
|
+
You can use the sinatra-flash gem to flash messages through to the thymeleaf template
|
56
58
|
|
59
|
+
Just add this to your route:
|
60
|
+
```
|
61
|
+
flash[:success] = "Whohoo!"
|
62
|
+
flash[:error] = "Damn!"
|
63
|
+
```
|
64
|
+
|
65
|
+
Also, add this to your template:
|
66
|
+
```
|
67
|
+
<div data-th-unless="${flash[:success].nil?}" class="alert alert-success">
|
68
|
+
<strong>Success!</strong>
|
69
|
+
<span data-th-text="${flash[:success]}"> That worked! </span>
|
70
|
+
</div>
|
71
|
+
<div data-th-unless="${flash[:error].nil?}" class="alert alert-danger">
|
72
|
+
<strong>Oups!</strong>
|
73
|
+
<span data-th-text="${flash[:error]}"> Something went wrong! </span>
|
74
|
+
</div>
|
75
|
+
```
|
76
|
+
|
77
|
+
And you should be good to go
|
data/lib/sinatra/thymeleaf.rb
CHANGED
@@ -9,6 +9,11 @@ module Sinatra
|
|
9
9
|
options, template = template, nil if template.is_a?(Hash)
|
10
10
|
template = lambda { block } if template.nil?
|
11
11
|
locals[:t] = lambda { |m| I18n.t(m) }
|
12
|
+
|
13
|
+
unless session['flash'].nil?
|
14
|
+
locals[:flash] = session['flash']
|
15
|
+
end
|
16
|
+
|
12
17
|
render :html, template, options, locals
|
13
18
|
end
|
14
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-thymeleaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Costea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thymeleaf
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
85
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.4.8
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Sinatra support for Thymeleaf.rb templates
|