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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -0
  3. data/lib/sinatra/thymeleaf.rb +5 -0
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba4dca5609d0784b443f23e11b4af05ed327c4e0
4
- data.tar.gz: abbb1a20442939eb4ae1f833118b1ce71f5b5c1b
3
+ metadata.gz: 4461236a061f630e5612a026f75fc9deeaba26c9
4
+ data.tar.gz: 39676324aa51a7d607fe3ab750dc13c9716e82be
5
5
  SHA512:
6
- metadata.gz: 1b418d6620f59f9ee55600af1cc8594a45c99c07a23671670ca855d1e3ef68518ec960e00007668df362503784e1c089f69be74534d09ec716a3586b3b6aff4c
7
- data.tar.gz: 5c833693110e66c1736e5a30dab67ccc6f33a20f477c1a8f31624df50be9eb4ba5d1f38b73c5c20fbda0f95e3417ee9a584faec39cc90bbb285d9dfb8d2a8079
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
@@ -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.0
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-07 00:00:00.000000000 Z
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.6.8
86
+ rubygems_version: 2.4.8
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Sinatra support for Thymeleaf.rb templates